We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6e443ae commit be2eabdCopy full SHA for be2eabd
src/GitVersionCore/Core/RepositoryMetadataProvider.cs
@@ -183,10 +183,12 @@ public Branch GetTargetBranch(string targetBranch)
183
{
184
// In the case where HEAD is not the desired branch, try to find the branch with matching name
185
desiredBranch = repository.Branches?
186
- .SingleOrDefault(b =>
+ .Where(b =>
187
b.CanonicalName.IsEquivalentTo(targetBranch) ||
188
b.FriendlyName.IsEquivalentTo(targetBranch) ||
189
- b.NameWithoutRemote().IsEquivalentTo(targetBranch));
+ b.NameWithoutRemote().IsEquivalentTo(targetBranch))
190
+ .OrderBy(b => b.IsRemote)
191
+ .FirstOrDefault();
192
193
// Failsafe in case the specified branch is invalid
194
desiredBranch ??= repository.Head;
0 commit comments