Skip to content

Commit 1c84f2d

Browse files
committed
fix: takes version from the current branch name even when its not from origin
1 parent 692c35a commit 1c84f2d

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/GitVersionCore/LibGitExtensions.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,18 @@ public static DateTimeOffset When(this Commit commit)
1414
return commit.Committer.When;
1515
}
1616

17-
/// <summary>
18-
/// Checks if the two branch objects refer to the same branch (have the same friendly name).
19-
/// </summary>
2017
public static string NameWithoutRemote(this Branch branch)
2118
{
22-
return branch.IsRemote ?
23-
branch.FriendlyName.Substring(branch.FriendlyName.IndexOf("/", StringComparison.Ordinal) + 1) :
24-
branch.FriendlyName;
19+
return branch.IsRemote
20+
? branch.FriendlyName.Substring(branch.FriendlyName.IndexOf("/", StringComparison.Ordinal) + 1)
21+
: branch.FriendlyName;
22+
}
23+
24+
public static string NameWithoutOrigin(this Branch branch)
25+
{
26+
return branch.IsRemote && branch.FriendlyName.StartsWith("origin/")
27+
? branch.FriendlyName.Substring("origin/".Length)
28+
: branch.FriendlyName;
2529
}
2630

2731
/// <summary>

src/GitVersionCore/VersionCalculation/BaseVersionCalculators/VersionInBranchNameBaseVersionStrategy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public override IEnumerable<BaseVersion> GetVersions(GitVersionContext context)
2121

2222
public IEnumerable<BaseVersion> GetVersions(GitVersionContext context, string tagPrefixRegex, Branch currentBranch)
2323
{
24-
if (!context.FullConfiguration.IsReleaseBranch(currentBranch.NameWithoutRemote()))
24+
if (!context.FullConfiguration.IsReleaseBranch(currentBranch.NameWithoutOrigin()))
2525
{
2626
yield break;
2727
}

0 commit comments

Comments
 (0)