diff --git a/src/GitVersion.LibGit2Sharp/Git/Branch.cs b/src/GitVersion.LibGit2Sharp/Git/Branch.cs
index 321b129801..bf635d9958 100644
--- a/src/GitVersion.LibGit2Sharp/Git/Branch.cs
+++ b/src/GitVersion.LibGit2Sharp/Git/Branch.cs
@@ -1,5 +1,4 @@
using System;
-using GitVersion.Extensions;
using GitVersion.Helpers;
namespace GitVersion
@@ -50,15 +49,6 @@ public ICommitCollection? Commits
}
}
- ///
- /// Checks if the two branch objects refer to the same branch (have the same friendly name).
- ///
- public bool IsSameBranch(IBranch otherBranch)
- {
- // For each branch, fixup the friendly name if the branch is remote.
- var otherBranchFriendlyName = otherBranch.NameWithoutRemote;
- return otherBranchFriendlyName.IsEquivalentTo(NameWithoutRemote);
- }
public bool IsDetachedHead => CanonicalName.Equals("(no branch)", StringComparison.OrdinalIgnoreCase);
public bool IsRemote => innerBranch.IsRemote;
diff --git a/src/GitVersion.LibGit2Sharp/Git/BranchCollection.cs b/src/GitVersion.LibGit2Sharp/Git/BranchCollection.cs
index 36dc711b3d..0e0bee4d6e 100644
--- a/src/GitVersion.LibGit2Sharp/Git/BranchCollection.cs
+++ b/src/GitVersion.LibGit2Sharp/Git/BranchCollection.cs
@@ -24,7 +24,7 @@ public IBranch? this[string friendlyName]
}
public IEnumerable ExcludeBranches(IEnumerable branchesToExclude) =>
- this.Where(b => branchesToExclude.All(bte => !b.IsSameBranch(bte)));
+ this.Where(b => branchesToExclude.All(bte => !b.Equals(bte)));
public void UpdateTrackedBranch(IBranch branch, string remoteTrackingReferenceName) =>
innerCollection.Update((Branch)branch, b => b.TrackedBranch = remoteTrackingReferenceName);
}
diff --git a/src/GitVersionCore/Configuration/BranchConfigurationCalculator.cs b/src/GitVersionCore/Configuration/BranchConfigurationCalculator.cs
index a606bf8a9e..aaf9bfa1fb 100644
--- a/src/GitVersionCore/Configuration/BranchConfigurationCalculator.cs
+++ b/src/GitVersionCore/Configuration/BranchConfigurationCalculator.cs
@@ -70,7 +70,7 @@ private BranchConfig InheritBranchConfiguration(IBranch targetBranch, BranchConf
excludedInheritBranches ??= repositoryMetadataProvider.GetExcludedInheritBranches(configuration).ToList();
- excludedBranches = excludedBranches.Where(b => excludedInheritBranches.All(bte => !b.IsSameBranch(bte))).ToArray();
+ excludedBranches = excludedBranches.Where(b => excludedInheritBranches.All(bte => !b.Equals(bte))).ToArray();
// Add new excluded branches.
foreach (var excludedBranch in excludedBranches)
{
@@ -139,7 +139,7 @@ private BranchConfig InheritBranchConfiguration(IBranch targetBranch, BranchConf
log.Warning(errorMessage + System.Environment.NewLine + "Falling back to " + branchName + " branch config");
// To prevent infinite loops, make sure that a new branch was chosen.
- if (targetBranch.IsSameBranch(chosenBranch))
+ if (targetBranch.Equals(chosenBranch))
{
var developOrMasterConfig =
ChooseMasterOrDevelopIncrementStrategyIfTheChosenBranchIsOneOfThem(
diff --git a/src/GitVersionCore/Core/Abstractions/Git/IBranch.cs b/src/GitVersionCore/Core/Abstractions/Git/IBranch.cs
index ed034039fd..07fe44f9b5 100644
--- a/src/GitVersionCore/Core/Abstractions/Git/IBranch.cs
+++ b/src/GitVersionCore/Core/Abstractions/Git/IBranch.cs
@@ -13,6 +13,5 @@ public interface IBranch : IEquatable, IComparable
bool IsTracking { get; }
bool IsDetachedHead { get; }
ICommitCollection Commits { get; }
- bool IsSameBranch(IBranch otherBranch);
}
}
diff --git a/src/GitVersionCore/Core/RepositoryMetadataProvider.cs b/src/GitVersionCore/Core/RepositoryMetadataProvider.cs
index e2863127b7..5e0f35ed73 100644
--- a/src/GitVersionCore/Core/RepositoryMetadataProvider.cs
+++ b/src/GitVersionCore/Core/RepositoryMetadataProvider.cs
@@ -303,7 +303,7 @@ public BranchCommit FindCommitBranchWasBranchedFrom(IBranch branch, Config confi
}
var possibleBranches = GetMergeCommitsForBranch(branch, configuration, excludedBranches)
- .Where(b => !branch.IsSameBranch(b.Branch))
+ .Where(b => !branch.Equals(b.Branch))
.ToList();
if (possibleBranches.Count > 1)
diff --git a/src/GitVersionCore/VersionCalculation/MainlineVersionCalculator.cs b/src/GitVersionCore/VersionCalculation/MainlineVersionCalculator.cs
index f43b3ba192..292fa0339c 100644
--- a/src/GitVersionCore/VersionCalculation/MainlineVersionCalculator.cs
+++ b/src/GitVersionCore/VersionCalculation/MainlineVersionCalculator.cs
@@ -43,7 +43,7 @@ public SemanticVersion FindMainlineModeVersion(BaseVersion baseVersion)
var mainlineTip = mainline.Tip;
// when the current branch is not mainline, find the effective mainline tip for versioning the branch
- if (!context.CurrentBranch.IsSameBranch(mainline))
+ if (!context.CurrentBranch.Equals(mainline))
{
mergeBase = FindMergeBaseBeforeForwardMerge(baseVersion.BaseVersionSource, mainline, out mainlineTip);
log.Info($"Current branch ({context.CurrentBranch.FriendlyName}) was branch from {mergeBase}");
@@ -71,7 +71,7 @@ public SemanticVersion FindMainlineModeVersion(BaseVersion baseVersion)
mainlineVersion.BuildMetaData = CreateVersionBuildMetaData(mergeBase);
// branches other than master always get a bump for the act of branching
- if ((!context.CurrentBranch.IsSameBranch(mainline)) && (string.IsNullOrEmpty(context.Configuration.NextVersion)))
+ if ((!context.CurrentBranch.Equals(mainline)) && (string.IsNullOrEmpty(context.Configuration.NextVersion)))
{
var branchIncrement = FindMessageIncrement(null, context.CurrentCommit, mergeBase, mainlineCommitLog);
log.Info($"Performing {branchIncrement} increment for current branch ");
@@ -140,7 +140,7 @@ private IBranch GetMainline(ICommit baseVersionSource)
}
// prefer current branch, if it is a mainline branch
- if (possibleMainlineBranches.Any(context.CurrentBranch.IsSameBranch))
+ if (possibleMainlineBranches.Any(context.CurrentBranch.Equals))
{
log.Info($"Choosing {context.CurrentBranch.FriendlyName} as mainline because it is the current branch");
return context.CurrentBranch;