Skip to content

Commit 0bc9155

Browse files
author
Gary Ewan Park
committed
(#284) Skip creation of HEAD branch
- Based on a suggestion from @nulltoken, skipping the creation of the HEAD branch, if it exists in the list of branches to create. - This was causing an issue when running on AppVeyor - This can be seen working here: https://ci.appveyor.com/project/GaryEwanPark/webapisample/build/0.2.0-unstable.23+23%20(Build%2034)
1 parent 332480f commit 0bc9155

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

GitVersionCore/BuildServers/GitHelper.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,12 @@ static IEnumerable<DirectReference> GetRemoteTipsForAnonymousUser(Repository rep
172172
static void CreateMissingLocalBranchesFromRemoteTrackingOnes(Repository repo, string remoteName)
173173
{
174174
var prefix = string.Format("refs/remotes/{0}/", remoteName);
175+
var remoteHeadCanonicalName = string.Format("{0}{1}", prefix, "HEAD");
175176

176-
foreach (var remoteTrackingReference in repo.Refs.FromGlob(prefix + "*"))
177+
foreach (var remoteTrackingReference in repo.Refs.FromGlob(prefix + "*").Where(r => r.CanonicalName != remoteHeadCanonicalName))
177178
{
178179
var localCanonicalName = "refs/heads/" + remoteTrackingReference.CanonicalName.Substring(prefix.Length);
180+
179181
if (repo.Refs.Any(x => x.CanonicalName == localCanonicalName))
180182
{
181183
Logger.WriteInfo(string.Format("Skipping local branch creation since it already exists '{0}'.", remoteTrackingReference.CanonicalName));

0 commit comments

Comments
 (0)