Skip to content

Commit ba9d04b

Browse files
authored
Merge pull request #3902 from HHobeck/feature/Replace-the-version-mode-Mainline-Part-V
Replace the version mode Mainline in 6.x (Part V)
2 parents f185574 + 213ac94 commit ba9d04b

File tree

81 files changed

+40364
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+40364
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
using GitVersion.Configuration;
2+
using GitVersion.Core.Tests;
3+
using GitVersion.Core.Tests.IntegrationTests;
4+
using GitVersion.VersionCalculation;
5+
6+
namespace GitVersion.Core.TrunkBased;
7+
8+
internal partial class TrunkBasedScenariosWithAGitFlow
9+
{
10+
[Parallelizable(ParallelScope.All)]
11+
public class GivenADevelopBranchWithOneCommitMergedToMainWhen
12+
{
13+
private EmptyRepositoryFixture? fixture;
14+
15+
private static GitFlowConfigurationBuilder TrunkBasedBuilder => GitFlowConfigurationBuilder.New.WithLabel(null)
16+
.WithVersionStrategy(VersionStrategies.TrunkBased)
17+
.WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment))
18+
.WithBranch("develop", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment));
19+
20+
[OneTimeSetUp]
21+
public void OneTimeSetUp()
22+
{
23+
// * 55 minutes ago (HEAD -> main)
24+
// |\
25+
// | * 56 minutes ago (develop)
26+
// |/
27+
// * 58 minutes ago
28+
29+
fixture = new EmptyRepositoryFixture("main");
30+
31+
fixture.MakeACommit("A");
32+
fixture.BranchTo("develop");
33+
fixture.MakeACommit("B");
34+
fixture.MergeTo("main");
35+
}
36+
37+
[OneTimeTearDown]
38+
public void OneTimeTearDown() => fixture?.Dispose();
39+
40+
[TestCase(IncrementStrategy.None, IncrementStrategy.None, ExpectedResult = "0.0.0-alpha.1+2")]
41+
[TestCase(IncrementStrategy.None, IncrementStrategy.Patch, ExpectedResult = "0.0.1-alpha.1+2")]
42+
[TestCase(IncrementStrategy.None, IncrementStrategy.Minor, ExpectedResult = "0.1.0-alpha.1+2")]
43+
[TestCase(IncrementStrategy.None, IncrementStrategy.Major, ExpectedResult = "1.0.0-alpha.1+2")]
44+
45+
[TestCase(IncrementStrategy.Patch, IncrementStrategy.None, ExpectedResult = "0.0.1-alpha.1+2")]
46+
[TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, ExpectedResult = "0.0.2-alpha.1+2")]
47+
[TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, ExpectedResult = "0.1.0-alpha.1+2")]
48+
[TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, ExpectedResult = "1.0.0-alpha.1+2")]
49+
50+
[TestCase(IncrementStrategy.Minor, IncrementStrategy.None, ExpectedResult = "0.1.0-alpha.1+2")]
51+
[TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, ExpectedResult = "0.1.1-alpha.1+2")]
52+
[TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, ExpectedResult = "0.2.0-alpha.1+2")]
53+
[TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, ExpectedResult = "1.0.0-alpha.1+2")]
54+
55+
[TestCase(IncrementStrategy.Major, IncrementStrategy.None, ExpectedResult = "1.0.0-alpha.1+2")]
56+
[TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, ExpectedResult = "1.0.1-alpha.1+2")]
57+
[TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, ExpectedResult = "1.1.0-alpha.1+2")]
58+
[TestCase(IncrementStrategy.Major, IncrementStrategy.Major, ExpectedResult = "2.0.0-alpha.1+2")]
59+
public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment)
60+
{
61+
IGitVersionConfiguration trunkBased = TrunkBasedBuilder
62+
.WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null))
63+
.WithBranch("develop", _ => _.WithIncrement(increment))
64+
.Build();
65+
66+
return fixture!.GetVersion(trunkBased).FullSemVer;
67+
}
68+
69+
[TestCase(IncrementStrategy.None, IncrementStrategy.None, ExpectedResult = "0.0.0-2+2")]
70+
[TestCase(IncrementStrategy.None, IncrementStrategy.Patch, ExpectedResult = "0.0.1-1+2")]
71+
[TestCase(IncrementStrategy.None, IncrementStrategy.Minor, ExpectedResult = "0.1.0-1+2")]
72+
[TestCase(IncrementStrategy.None, IncrementStrategy.Major, ExpectedResult = "1.0.0-1+2")]
73+
74+
[TestCase(IncrementStrategy.Patch, IncrementStrategy.None, ExpectedResult = "0.0.1-2+2")]
75+
[TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, ExpectedResult = "0.0.2-1+2")]
76+
[TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, ExpectedResult = "0.1.0-1+2")]
77+
[TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, ExpectedResult = "1.0.0-1+2")]
78+
79+
[TestCase(IncrementStrategy.Minor, IncrementStrategy.None, ExpectedResult = "0.1.0-2+2")]
80+
[TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, ExpectedResult = "0.1.1-1+2")]
81+
[TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, ExpectedResult = "0.2.0-1+2")]
82+
[TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, ExpectedResult = "1.0.0-1+2")]
83+
84+
[TestCase(IncrementStrategy.Major, IncrementStrategy.None, ExpectedResult = "1.0.0-2+2")]
85+
[TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, ExpectedResult = "1.0.1-1+2")]
86+
[TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, ExpectedResult = "1.1.0-1+2")]
87+
[TestCase(IncrementStrategy.Major, IncrementStrategy.Major, ExpectedResult = "2.0.0-1+2")]
88+
public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment)
89+
{
90+
IGitVersionConfiguration trunkBased = TrunkBasedBuilder
91+
.WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty))
92+
.WithBranch("develop", _ => _.WithIncrement(increment))
93+
.Build();
94+
95+
return fixture!.GetVersion(trunkBased).FullSemVer;
96+
}
97+
}
98+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
using GitVersion.Configuration;
2+
using GitVersion.Core.Tests;
3+
using GitVersion.Core.Tests.IntegrationTests;
4+
using GitVersion.VersionCalculation;
5+
6+
namespace GitVersion.Core.TrunkBased;
7+
8+
internal partial class TrunkBasedScenariosWithAGitFlow
9+
{
10+
[Parallelizable(ParallelScope.All)]
11+
public class GivenADevelopBranchWithOneCommitMergedToMainWhenMergedCommitTaggedAsStable
12+
{
13+
private EmptyRepositoryFixture? fixture;
14+
15+
private static GitFlowConfigurationBuilder TrunkBasedBuilder => GitFlowConfigurationBuilder.New.WithLabel(null)
16+
.WithVersionStrategy(VersionStrategies.TrunkBased)
17+
.WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment))
18+
.WithBranch("develop", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment));
19+
20+
[OneTimeSetUp]
21+
public void OneTimeSetUp()
22+
{
23+
// * 55 minutes ago (tag: 1.0.0, main)
24+
// |\
25+
// | * 56 minutes ago (HEAD -> develop)
26+
// |/
27+
// * 58 minutes ago
28+
29+
fixture = new EmptyRepositoryFixture("main");
30+
31+
fixture.MakeACommit("A");
32+
fixture.BranchTo("develop");
33+
fixture.MakeACommit("B");
34+
fixture.MergeTo("main");
35+
fixture.ApplyTag("1.0.0");
36+
fixture.Checkout("develop");
37+
}
38+
39+
[OneTimeTearDown]
40+
public void OneTimeTearDown() => fixture?.Dispose();
41+
42+
[TestCase(IncrementStrategy.None, IncrementStrategy.None, ExpectedResult = "1.0.0-alpha.1+0")]
43+
[TestCase(IncrementStrategy.None, IncrementStrategy.Patch, ExpectedResult = "1.0.1-alpha.1+0")]
44+
[TestCase(IncrementStrategy.None, IncrementStrategy.Minor, ExpectedResult = "1.1.0-alpha.1+0")]
45+
[TestCase(IncrementStrategy.None, IncrementStrategy.Major, ExpectedResult = "2.0.0-alpha.1+0")]
46+
47+
[TestCase(IncrementStrategy.Patch, IncrementStrategy.None, ExpectedResult = "1.0.0-alpha.1+0")]
48+
[TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, ExpectedResult = "1.0.1-alpha.1+0")]
49+
[TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, ExpectedResult = "1.1.0-alpha.1+0")]
50+
[TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, ExpectedResult = "2.0.0-alpha.1+0")]
51+
52+
[TestCase(IncrementStrategy.Minor, IncrementStrategy.None, ExpectedResult = "1.0.0-alpha.1+0")]
53+
[TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, ExpectedResult = "1.0.1-alpha.1+0")]
54+
[TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, ExpectedResult = "1.1.0-alpha.1+0")]
55+
[TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, ExpectedResult = "2.0.0-alpha.1+0")]
56+
57+
[TestCase(IncrementStrategy.Major, IncrementStrategy.None, ExpectedResult = "1.0.0-alpha.1+0")]
58+
[TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, ExpectedResult = "1.0.1-alpha.1+0")]
59+
[TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, ExpectedResult = "1.1.0-alpha.1+0")]
60+
[TestCase(IncrementStrategy.Major, IncrementStrategy.Major, ExpectedResult = "2.0.0-alpha.1+0")]
61+
public string GetVersionWithTrackMergeTargetOnDevelop(IncrementStrategy incrementOnMain, IncrementStrategy increment)
62+
{
63+
IGitVersionConfiguration trunkBased = TrunkBasedBuilder
64+
.WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null))
65+
.WithBranch("develop", _ => _.WithIncrement(increment).WithTrackMergeTarget(true))
66+
.Build();
67+
68+
return fixture!.GetVersion(trunkBased).FullSemVer;
69+
}
70+
71+
[TestCase(IncrementStrategy.None, IncrementStrategy.None, ExpectedResult = "0.0.0-alpha.1+2")]
72+
[TestCase(IncrementStrategy.None, IncrementStrategy.Patch, ExpectedResult = "0.0.1-alpha.1+2")]
73+
[TestCase(IncrementStrategy.None, IncrementStrategy.Minor, ExpectedResult = "0.1.0-alpha.1+2")]
74+
[TestCase(IncrementStrategy.None, IncrementStrategy.Major, ExpectedResult = "1.0.0-alpha.1+2")]
75+
76+
[TestCase(IncrementStrategy.Patch, IncrementStrategy.None, ExpectedResult = "0.0.0-alpha.1+2")]
77+
[TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, ExpectedResult = "0.0.1-alpha.1+2")]
78+
[TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, ExpectedResult = "0.1.0-alpha.1+2")]
79+
[TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, ExpectedResult = "1.0.0-alpha.1+2")]
80+
81+
[TestCase(IncrementStrategy.Minor, IncrementStrategy.None, ExpectedResult = "0.0.0-alpha.1+2")]
82+
[TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, ExpectedResult = "0.0.1-alpha.1+2")]
83+
[TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, ExpectedResult = "0.1.0-alpha.1+2")]
84+
[TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, ExpectedResult = "1.0.0-alpha.1+2")]
85+
86+
[TestCase(IncrementStrategy.Major, IncrementStrategy.None, ExpectedResult = "0.0.0-alpha.1+2")]
87+
[TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, ExpectedResult = "0.0.1-alpha.1+2")]
88+
[TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, ExpectedResult = "0.1.0-alpha.1+2")]
89+
[TestCase(IncrementStrategy.Major, IncrementStrategy.Major, ExpectedResult = "1.0.0-alpha.1+2")]
90+
public string GetVersionWithNoTrackMergeTargetOnDevelop(IncrementStrategy incrementOnMain, IncrementStrategy increment)
91+
{
92+
IGitVersionConfiguration trunkBased = TrunkBasedBuilder
93+
.WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null))
94+
.WithBranch("develop", _ => _.WithIncrement(increment).WithTrackMergeTarget(false))
95+
.Build();
96+
97+
return fixture!.GetVersion(trunkBased).FullSemVer;
98+
}
99+
}
100+
}

0 commit comments

Comments
 (0)