Skip to content

Commit 3a6b123

Browse files
enriquerasoasbjornu
authored andcommitted
Add unit tests in SupportBranchScenarios
1 parent 7576b44 commit 3a6b123

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

Diff for: src/GitVersion.Core.Tests/IntegrationTests/SupportBranchScenarios.cs

+27
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,31 @@ public void WhenSupportIsBranchedAndTaggedFromAnotherSupportEnsureNewMinorIsUsed
7171

7272
fixture.AssertFullSemver("1.3.1+2");
7373
}
74+
75+
[Test]
76+
public void WhenSupportIsBranchedFromMainWithSpecificTag()
77+
{
78+
using var fixture = new EmptyRepositoryFixture();
79+
fixture.Repository.MakeACommit();
80+
fixture.AssertFullSemver("0.1.0+0");
81+
82+
fixture.Repository.ApplyTag("1.4.0-rc");
83+
fixture.Repository.MakeACommit();
84+
fixture.Repository.CreateBranch("support/1");
85+
Commands.Checkout(fixture.Repository, "support/1");
86+
fixture.AssertFullSemver("1.4.0+1");
87+
}
88+
89+
[Test]
90+
public void WhenSupportIsBranchedFromMainWithSpecificTagOnCommit()
91+
{
92+
using var fixture = new EmptyRepositoryFixture();
93+
fixture.Repository.MakeACommit();
94+
fixture.AssertFullSemver("0.1.0+0");
95+
96+
fixture.Repository.ApplyTag("1.4.0-rc");
97+
fixture.Repository.CreateBranch("support/1");
98+
Commands.Checkout(fixture.Repository, "support/1");
99+
fixture.AssertFullSemver("1.4.0");
100+
}
74101
}

Diff for: src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs

+6
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ public NextVersion FindVersion()
9797
{
9898
// set the commit count on the tagged ver
9999
taggedSemanticVersion.BuildMetaData.CommitsSinceVersionSource = semver.BuildMetaData?.CommitsSinceVersionSource;
100+
101+
// set the updated prerelease tag when it doesn't match with prerelease tag defined in branch configuration
102+
if (preReleaseTagDoesNotMatchConfiguration)
103+
{
104+
taggedSemanticVersion.PreReleaseTag = semver.PreReleaseTag;
105+
}
100106
}
101107
}
102108

0 commit comments

Comments
 (0)