Skip to content

Commit c0ecaf0

Browse files
committed
Little bit of refactoring for LibGitExtensions
1 parent 0e76113 commit c0ecaf0

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/GitVersionCore/LibGitExtensions.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,21 @@ public static DateTimeOffset When(this Commit commit)
1717
/// <summary>
1818
/// Checks if the two branch objects refer to the same branch (have the same friendly name).
1919
/// </summary>
20-
public static bool IsSameBranch(this Branch branch, Branch otherBranch)
20+
public static string NameWithoutRemote(this Branch branch)
2121
{
22-
// For each branch, fixup the friendly name if the branch is remote.
23-
var otherBranchFriendlyName = otherBranch.IsRemote ?
24-
otherBranch.FriendlyName.Substring(otherBranch.FriendlyName.IndexOf("/", StringComparison.Ordinal) + 1) :
25-
otherBranch.FriendlyName;
26-
var branchFriendlyName = branch.IsRemote ?
22+
return branch.IsRemote ?
2723
branch.FriendlyName.Substring(branch.FriendlyName.IndexOf("/", StringComparison.Ordinal) + 1) :
2824
branch.FriendlyName;
25+
}
26+
27+
/// <summary>
28+
/// Checks if the two branch objects refer to the same branch (have the same friendly name).
29+
/// </summary>
30+
public static bool IsSameBranch(this Branch branch, Branch otherBranch)
31+
{
32+
// For each branch, fixup the friendly name if the branch is remote.
33+
var otherBranchFriendlyName = otherBranch.NameWithoutRemote();
34+
var branchFriendlyName = branch.NameWithoutRemote();
2935

3036
return otherBranchFriendlyName == branchFriendlyName;
3137
}

0 commit comments

Comments
 (0)