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

Commit 2652b5e

Browse files
When a specific branch is specified in GitRepositoryHelper, it should not checkout the *default branch* of the repository with the specified branch name, but it should checkout the actual remote branch
1 parent 459c2be commit 2652b5e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

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)