|
| 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 GivenAFeatureBranchWithAMergeCommitFromMainMergedBackToMainWhen |
| 12 | + { |
| 13 | + private EmptyRepositoryFixture? fixture; |
| 14 | + |
| 15 | + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New.WithLabel(null) |
| 16 | + .WithVersionStrategy(VersionStrategies.TrunkBased) |
| 17 | + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) |
| 18 | + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); |
| 19 | + |
| 20 | + [OneTimeSetUp] |
| 21 | + public void OneTimeSetUp() |
| 22 | + { |
| 23 | + // * 52 minutes ago (HEAD -> main) |
| 24 | + // |\ |
| 25 | + // | * 53 minutes ago (feature/foo) |
| 26 | + // | |\ |
| 27 | + // | |/ |
| 28 | + // |/| |
| 29 | + // C | 54 minutes ago |
| 30 | + // | B 56 minutes ago |
| 31 | + // |/ |
| 32 | + // A 58 minutes ago |
| 33 | + |
| 34 | + fixture = new EmptyRepositoryFixture("main"); |
| 35 | + |
| 36 | + fixture.MakeACommit("A"); |
| 37 | + fixture.BranchTo("feature/foo"); |
| 38 | + fixture.MakeACommit("B"); |
| 39 | + fixture.Checkout("main"); |
| 40 | + fixture.MakeACommit("C"); |
| 41 | + fixture.Checkout("main"); |
| 42 | + fixture.MergeTo("feature/foo"); |
| 43 | + fixture.MergeTo("main", removeBranchAfterMerging: true); |
| 44 | + } |
| 45 | + |
| 46 | + [OneTimeTearDown] |
| 47 | + public void OneTimeTearDown() => fixture?.Dispose(); |
| 48 | + |
| 49 | + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.1+3")] |
| 50 | + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+3")] |
| 51 | + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+3")] |
| 52 | + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+3")] |
| 53 | + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.1+3")] |
| 54 | + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-3+3")] |
| 55 | + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+3")] |
| 56 | + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+3")] |
| 57 | + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+3")] |
| 58 | + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-3+3")] |
| 59 | + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.3+3")] |
| 60 | + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+3")] |
| 61 | + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+3")] |
| 62 | + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+3")] |
| 63 | + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.3+3")] |
| 64 | + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.3+3")] |
| 65 | + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+3")] |
| 66 | + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+3")] |
| 67 | + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+3")] |
| 68 | + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.3+3")] |
| 69 | + |
| 70 | + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.2-foo.1+3")] |
| 71 | + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-foo.1+3")] |
| 72 | + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+3")] |
| 73 | + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+3")] |
| 74 | + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-foo.1+3")] |
| 75 | + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-2+3")] |
| 76 | + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+3")] |
| 77 | + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+3")] |
| 78 | + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+3")] |
| 79 | + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+3")] |
| 80 | + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.2+3")] |
| 81 | + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+3")] |
| 82 | + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+3")] |
| 83 | + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+3")] |
| 84 | + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.3-foo.1+3")] |
| 85 | + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.2+3")] |
| 86 | + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+3")] |
| 87 | + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+3")] |
| 88 | + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+3")] |
| 89 | + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+3")] |
| 90 | + |
| 91 | + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-foo.1+3")] |
| 92 | + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-foo.1+3")] |
| 93 | + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-foo.1+3")] |
| 94 | + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+3")] |
| 95 | + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-foo.1+3")] |
| 96 | + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-2+3")] |
| 97 | + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+3")] |
| 98 | + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+3")] |
| 99 | + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+3")] |
| 100 | + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+3")] |
| 101 | + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.2+3")] |
| 102 | + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+3")] |
| 103 | + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.0-foo.1+3")] |
| 104 | + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+3")] |
| 105 | + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.3.0-foo.1+3")] |
| 106 | + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.2+3")] |
| 107 | + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+3")] |
| 108 | + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+3")] |
| 109 | + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+3")] |
| 110 | + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+3")] |
| 111 | + |
| 112 | + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-foo.1+3")] |
| 113 | + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-foo.1+3")] |
| 114 | + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-foo.1+3")] |
| 115 | + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-foo.1+3")] |
| 116 | + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-foo.1+3")] |
| 117 | + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-2+3")] |
| 118 | + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+3")] |
| 119 | + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+3")] |
| 120 | + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+3")] |
| 121 | + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+3")] |
| 122 | + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.2+3")] |
| 123 | + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+3")] |
| 124 | + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+3")] |
| 125 | + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+3")] |
| 126 | + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+3")] |
| 127 | + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.2+3")] |
| 128 | + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+3")] |
| 129 | + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+3")] |
| 130 | + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+3")] |
| 131 | + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+3")] |
| 132 | + public string GetVersion(IncrementStrategy increment, IncrementStrategy incrementOnFeature, string? label) |
| 133 | + { |
| 134 | + IGitVersionConfiguration trunkBased = TrunkBasedBuilder |
| 135 | + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label)) |
| 136 | + .WithBranch("feature", _ => _.WithIncrement(incrementOnFeature)) |
| 137 | + .Build(); |
| 138 | + |
| 139 | + return fixture!.GetVersion(trunkBased).FullSemVer; |
| 140 | + } |
| 141 | + |
| 142 | + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.1+3")] |
| 143 | + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+3")] |
| 144 | + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+3")] |
| 145 | + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+3")] |
| 146 | + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.1+3")] |
| 147 | + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-3+3")] |
| 148 | + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+3")] |
| 149 | + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+3")] |
| 150 | + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+3")] |
| 151 | + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-3+3")] |
| 152 | + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.3+3")] |
| 153 | + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+3")] |
| 154 | + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+3")] |
| 155 | + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+3")] |
| 156 | + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.3+3")] |
| 157 | + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.3+3")] |
| 158 | + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+3")] |
| 159 | + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+3")] |
| 160 | + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+3")] |
| 161 | + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.3+3")] |
| 162 | + |
| 163 | + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.3-foo.1+3")] |
| 164 | + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-foo.1+3")] |
| 165 | + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+3")] |
| 166 | + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+3")] |
| 167 | + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-foo.1+3")] |
| 168 | + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.3-1+3")] |
| 169 | + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+3")] |
| 170 | + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+3")] |
| 171 | + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+3")] |
| 172 | + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+3")] |
| 173 | + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.3-foo.1+3")] |
| 174 | + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+3")] |
| 175 | + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+3")] |
| 176 | + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+3")] |
| 177 | + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.3-foo.1+3")] |
| 178 | + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.3-bar.1+3")] |
| 179 | + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+3")] |
| 180 | + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+3")] |
| 181 | + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+3")] |
| 182 | + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+3")] |
| 183 | + |
| 184 | + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.3.0-foo.1+3")] |
| 185 | + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.3.0-foo.1+3")] |
| 186 | + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-foo.1+3")] |
| 187 | + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+3")] |
| 188 | + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-foo.1+3")] |
| 189 | + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.3.0-1+3")] |
| 190 | + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.3.0-1+3")] |
| 191 | + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+3")] |
| 192 | + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+3")] |
| 193 | + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+3")] |
| 194 | + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.3.0-foo.1+3")] |
| 195 | + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.3.0-foo.1+3")] |
| 196 | + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.0-foo.1+3")] |
| 197 | + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+3")] |
| 198 | + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.3.0-foo.1+3")] |
| 199 | + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.3.0-bar.1+3")] |
| 200 | + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.3.0-bar.1+3")] |
| 201 | + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+3")] |
| 202 | + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+3")] |
| 203 | + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+3")] |
| 204 | + |
| 205 | + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "3.0.0-foo.1+3")] |
| 206 | + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "3.0.0-foo.1+3")] |
| 207 | + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "3.0.0-foo.1+3")] |
| 208 | + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-foo.1+3")] |
| 209 | + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-foo.1+3")] |
| 210 | + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "3.0.0-1+3")] |
| 211 | + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "3.0.0-1+3")] |
| 212 | + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "3.0.0-1+3")] |
| 213 | + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+3")] |
| 214 | + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+3")] |
| 215 | + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "3.0.0-foo.1+3")] |
| 216 | + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "3.0.0-foo.1+3")] |
| 217 | + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "3.0.0-foo.1+3")] |
| 218 | + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+3")] |
| 219 | + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+3")] |
| 220 | + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "3.0.0-bar.1+3")] |
| 221 | + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "3.0.0-bar.1+3")] |
| 222 | + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "3.0.0-bar.1+3")] |
| 223 | + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+3")] |
| 224 | + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+3")] |
| 225 | + public string GetVersionWithPreventIncrementOfMergedBranchVersionFalseOnMain( |
| 226 | + IncrementStrategy increment, IncrementStrategy incrementOnFeature, string? label) |
| 227 | + { |
| 228 | + IGitVersionConfiguration trunkBased = TrunkBasedBuilder |
| 229 | + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label).WithPreventIncrementOfMergedBranchVersion(false)) |
| 230 | + .WithBranch("feature", _ => _.WithIncrement(incrementOnFeature)) |
| 231 | + .Build(); |
| 232 | + |
| 233 | + return fixture!.GetVersion(trunkBased).FullSemVer; |
| 234 | + } |
| 235 | + } |
| 236 | +} |
0 commit comments