Skip to content
This repository was archived by the owner on Jun 27, 2019. It is now read-only.

Commit 98e7127

Browse files
authored
Merge pull request #39 from GitTools/pr/checkout-bug
Fix checkout bug in GitRepositoryHelper
2 parents 459c2be + b15f5a6 commit 98e7127

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
install:
22
- choco install gitversion.portable -pre -y
3-
- cinst gitlink -pre -y
3+
- cinst gitlink -y
44

55
platform:
66
- Any CPU

src/GitTools.Core/GitTools.Core.Shared/Git/Helpers/GitRepositoryHelper.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,17 @@ static void EnsureLocalBranchExistsForCurrentBranch(Repository repo, string curr
139139
var isRef = currentBranch.Contains("refs");
140140
var isBranch = currentBranch.Contains("refs/heads");
141141
var localCanonicalName = !isRef ? "refs/heads/" + currentBranch : isBranch ? currentBranch : currentBranch.Replace("refs/", "refs/heads/");
142+
142143
var repoTip = repo.Head.Tip;
144+
145+
// We currently have the rep.Head of the *default* branch, now we need to look up the right one
146+
var originCanonicalName = string.Format("origin/{0}", currentBranch);
147+
var originBranch = repo.Branches[originCanonicalName];
148+
if (originBranch != null)
149+
{
150+
repoTip = originBranch.Tip;
151+
}
152+
143153
var repoTipId = repoTip.Id;
144154

145155
if (repo.Branches.All(b => b.CanonicalName != localCanonicalName))

0 commit comments

Comments
 (0)