Skip to content

Commit 4ec6962

Browse files
committed
EnsurePullRequestWithIncrementMajorOnMainAndMinorOnFeatureBranch
1 parent 8bf4cac commit 4ec6962

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

src/GitVersion.Core.Tests/IntegrationTests/PullRequestScenarios.cs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using GitVersion.Configuration;
12
using GitVersion.Core.Tests.Helpers;
23
using LibGit2Sharp;
34

@@ -6,6 +7,48 @@ namespace GitVersion.Core.Tests.IntegrationTests;
67
[TestFixture]
78
public class PullRequestScenarios : TestBase
89
{
10+
/// <summary>
11+
/// GitHubFlow - Pull requests (increment major on main and minor on feature)
12+
/// </summary>
13+
[Test]
14+
public void EnsurePullRequestWithIncrementMajorOnMainAndMinorOnFeatureBranch()
15+
{
16+
var configuration = GitHubFlowConfigurationBuilder.New
17+
.WithBranch("main", _ => _
18+
.WithIncrement(IncrementStrategy.Major)
19+
).WithBranch("feature", _ => _
20+
.WithIncrement(IncrementStrategy.Minor)
21+
).Build();
22+
23+
using var fixture = new EmptyRepositoryFixture("main");
24+
25+
fixture.MakeACommit("A");
26+
27+
// ✅ succeeds as expected
28+
fixture.AssertFullSemver("1.0.0-1", configuration);
29+
30+
fixture.ApplyTag("1.0.0");
31+
fixture.BranchTo("feature/foo");
32+
fixture.MakeACommit("B");
33+
34+
// ✅ succeeds as expected
35+
fixture.AssertFullSemver("1.1.0-foo.1+1", configuration);
36+
37+
fixture.Checkout("main");
38+
fixture.BranchTo("pull/2/merge");
39+
fixture.MergeNoFF("feature/foo");
40+
41+
// ❌ expected: "2.0.0-PullRequest2.2"
42+
fixture.AssertFullSemver("1.1.0-PullRequest2.2", configuration);
43+
44+
fixture.Checkout("main");
45+
fixture.Remove("pull/2/merge");
46+
fixture.MergeNoFF("feature/foo");
47+
48+
// ✅ succeeds as expected
49+
fixture.AssertFullSemver("2.0.0-2", configuration);
50+
}
51+
952
[Test]
1053
public void CanCalculatePullRequestChanges()
1154
{

0 commit comments

Comments
 (0)