|
| 1 | +using GitVersion.Configuration; |
| 2 | +using GitVersion.Core.Tests.Helpers; |
| 3 | +using GitVersion.Extensions; |
| 4 | +using GitVersion.VersionCalculation; |
| 5 | +using LibGit2Sharp; |
| 6 | + |
| 7 | +namespace GitVersion.Core.Tests.IntegrationTests; |
| 8 | + |
| 9 | +[TestFixture] |
| 10 | +public class FailingTests : TestBase |
| 11 | +{ |
| 12 | + [Test(Description = "Failed test: Issue #1255, PR #1600, DevelopScenarios")] |
| 13 | + public void ShouldProvideTheCorrectVersionEvenIfPreReleaseLabelExistsInTheGitTagDevelop() |
| 14 | + { |
| 15 | + using var fixture = new EmptyRepositoryFixture(); |
| 16 | + fixture.Repository.MakeACommit(); |
| 17 | + fixture.ApplyTag("1.0.0-oreo.1"); |
| 18 | + fixture.BranchTo("develop"); |
| 19 | + fixture.Repository.MakeACommit(); |
| 20 | + fixture.AssertFullSemver("1.1.0-alpha.1"); |
| 21 | + } |
| 22 | + |
| 23 | + [Test(Description = "Failed test: Issue #1255, PR #1600, MainScenarios")] |
| 24 | + public void ShouldProvideTheCorrectVersionEvenIfPreReleaseLabelExistsInTheGitTagMain() |
| 25 | + { |
| 26 | + var configuration = GitFlowConfigurationBuilder.New |
| 27 | + .WithSemanticVersionFormat(SemanticVersionFormat.Loose) |
| 28 | + .WithNextVersion("5.0") |
| 29 | + .WithBranch(MainBranch, |
| 30 | + branchBuilder => branchBuilder.WithLabel("beta") |
| 31 | + .WithIncrement(IncrementStrategy.Patch) |
| 32 | + .WithVersioningMode(VersioningMode.ContinuousDeployment)) |
| 33 | + .Build(); |
| 34 | + |
| 35 | + using EmptyRepositoryFixture fixture = new(MainBranch); |
| 36 | + fixture.Repository.MakeACommit(); |
| 37 | + fixture.AssertFullSemver("5.0.0-beta.0", configuration); // why not "5.0.0-beta.1"? |
| 38 | + fixture.Repository.MakeACommit(); |
| 39 | + fixture.AssertFullSemver("5.0.0-beta.1", configuration); |
| 40 | + fixture.Repository.MakeATaggedCommit("v5.0.0-rc.1"); |
| 41 | + fixture.AssertFullSemver("5.0.0-rc.1", configuration); |
| 42 | + fixture.Repository.MakeACommit(); |
| 43 | + fixture.AssertFullSemver("5.0.1-beta.1", configuration); // test fails here, it generates "5.0.0-beta.1" which is not unique and lower than "5.0.0-rc.1" |
| 44 | + } |
| 45 | + |
| 46 | + [Test(Description = "Failed test: Issue #1844, PR #1845, VersionBumpingScenarios")] |
| 47 | + public void AppliedPrereleaseTagAfterBranchTagCausesVersionBump() |
| 48 | + { |
| 49 | + var configuration = GitFlowConfigurationBuilder.New |
| 50 | + .WithBranch(MainBranch, |
| 51 | + branchBuilder => branchBuilder.WithLabel("pre") |
| 52 | + .WithSourceBranches(ArraySegment<string>.Empty) |
| 53 | + .WithVersioningMode(VersioningMode.ContinuousDeployment)) |
| 54 | + .Build(); |
| 55 | + |
| 56 | + using var fixture = new EmptyRepositoryFixture(); |
| 57 | + fixture.Repository.MakeACommit(); |
| 58 | + fixture.Repository.MakeATaggedCommit("1.0.0-rc"); |
| 59 | + fixture.Repository.MakeACommit(); |
| 60 | + |
| 61 | + fixture.AssertFullSemver("1.0.1-pre.1", configuration); |
| 62 | + } |
| 63 | + |
| 64 | + [Test(Description = "Failed test: Issue #2034, PR #2059, MainlineDevelopmentMode")] |
| 65 | + public void MergingMainBranchToDevelopWithInheritIncrementShouldIncrementDevelopPatch() |
| 66 | + { |
| 67 | + var configuration = GitFlowConfigurationBuilder.New |
| 68 | + .WithAssemblyVersioningScheme(AssemblyVersioningScheme.MajorMinorPatch) |
| 69 | + .WithVersioningMode(VersioningMode.Mainline) |
| 70 | + .WithBranch(MainBranch, branchBuilder => branchBuilder.WithIncrement(IncrementStrategy.Patch)) |
| 71 | + .WithBranch("develop", branchBuilder => branchBuilder.WithIncrement(IncrementStrategy.Inherit)) |
| 72 | + .Build(); |
| 73 | + |
| 74 | + using var fixture = new EmptyRepositoryFixture(); |
| 75 | + fixture.MakeACommit($"initial in {MainBranch}"); |
| 76 | + fixture.AssertFullSemver("0.1.0", configuration); |
| 77 | + fixture.MakeACommit($"{MainBranch} change"); |
| 78 | + fixture.AssertFullSemver("0.1.1", configuration); |
| 79 | + |
| 80 | + fixture.BranchTo("develop"); |
| 81 | + fixture.AssertFullSemver("0.1.2-alpha.0", configuration); |
| 82 | + fixture.MakeACommit("develop change"); |
| 83 | + fixture.AssertFullSemver("0.1.2-alpha.1", configuration); |
| 84 | + |
| 85 | + fixture.Checkout(MainBranch); |
| 86 | + fixture.MakeACommit($"{MainBranch} hotfix"); |
| 87 | + fixture.AssertFullSemver("0.1.2", configuration); |
| 88 | + |
| 89 | + fixture.Checkout("develop"); |
| 90 | + fixture.MergeNoFF(MainBranch); |
| 91 | + fixture.AssertFullSemver("0.1.3-alpha.1", configuration); |
| 92 | + } |
| 93 | + |
| 94 | + [Test(Description = "Failed test: Issue #2693, PR #2696, HotfixBranchScenarios")] |
| 95 | + public void VersionNumberInHotfixBranchShouldBeConsideredWhenPreventIncrementOfMergedBranchVersion() |
| 96 | + { |
| 97 | + var configuration = GitFlowConfigurationBuilder.New |
| 98 | + .WithAssemblyVersioningScheme(AssemblyVersioningScheme.MajorMinorPatchTag) |
| 99 | + .WithAssemblyFileVersioningFormat("{MajorMinorPatch}.0") |
| 100 | + .WithVersioningMode(VersioningMode.ContinuousDeployment) |
| 101 | + .WithBranch("hotfix", |
| 102 | + branchBuilder => branchBuilder |
| 103 | + .WithPreventIncrementOfMergedBranchVersion(true) |
| 104 | + .WithRegularExpression("r^(origin/)?hotfix[/-]") |
| 105 | + ) |
| 106 | + .Build(); |
| 107 | + |
| 108 | + const string HotfixBranch = "hotfix/1.1.1"; |
| 109 | + const string ReleaseBranch = "release/1.1.0"; |
| 110 | + |
| 111 | + using var fixture = new BaseGitFlowRepositoryFixture("1.0.0"); |
| 112 | + Commands.Checkout(fixture.Repository, fixture.Repository.CreateBranch(ReleaseBranch)); |
| 113 | + fixture.MakeACommit(); |
| 114 | + Commands.Checkout(fixture.Repository, MainBranch); |
| 115 | + fixture.MergeNoFF(ReleaseBranch); |
| 116 | + fixture.Repository.CreateBranch(HotfixBranch); |
| 117 | + fixture.Repository.MakeACommit(); |
| 118 | + fixture.AssertFullSemver("1.1.1-ci.1", configuration); |
| 119 | + } |
| 120 | + |
| 121 | + [TestFixture(Description = "Failed test: Issue #2821, PR #2830")] |
| 122 | + public class XenoLibPackages : TestBase |
| 123 | + { |
| 124 | + private readonly GitVersionConfiguration configuration = GitFlowConfigurationBuilder.New |
| 125 | + .WithVersioningMode(VersioningMode.Mainline) |
| 126 | + .WithBranch("feature", branchBuilder => branchBuilder.WithIncrement(IncrementStrategy.Minor)) |
| 127 | + .WithBranch("pull-request", branchBuilder => branchBuilder.WithIncrement(IncrementStrategy.Minor)) |
| 128 | + .WithBranch("support", |
| 129 | + branchBuilder => branchBuilder |
| 130 | + .WithVersioningMode(VersioningMode.ContinuousDeployment) |
| 131 | + .WithLabel("beta") |
| 132 | + .WithIncrement(IncrementStrategy.Patch)) |
| 133 | + .Build(); |
| 134 | + |
| 135 | + [Test] |
| 136 | + public void IncrementFeatureByMinor() |
| 137 | + { |
| 138 | + using var fixture = new EmptyRepositoryFixture(); |
| 139 | + fixture.MakeATaggedCommit("0.1.0"); |
| 140 | + |
| 141 | + // feature workflow |
| 142 | + fixture.BranchTo("feature/foo", "foo"); |
| 143 | + fixture.MakeACommit(); |
| 144 | + fixture.AssertFullSemver("0.2.0-foo.1", this.configuration); |
| 145 | + fixture.MakeACommit(); |
| 146 | + fixture.AssertFullSemver("0.2.0-foo.2", this.configuration); |
| 147 | + fixture.Checkout(MainBranch); |
| 148 | + fixture.MergeNoFF("feature/foo"); |
| 149 | + fixture.AssertFullSemver("0.2.0", this.configuration); |
| 150 | + } |
| 151 | + |
| 152 | + [Test] |
| 153 | + public void CanCalculatePullRequestChanges() |
| 154 | + { |
| 155 | + using var fixture = new EmptyRepositoryFixture(); |
| 156 | + fixture.Repository.MakeATaggedCommit("1.0.0"); |
| 157 | + fixture.Repository.MakeATaggedCommit("1.1.0"); |
| 158 | + fixture.Repository.MakeATaggedCommit("2.0.0"); |
| 159 | + |
| 160 | + // feature branch |
| 161 | + Commands.Checkout(fixture.Repository, fixture.Repository.CreateBranch("feature/foo")); |
| 162 | + fixture.Repository.MakeACommit(); |
| 163 | + fixture.AssertFullSemver("2.1.0-foo.1", this.configuration); |
| 164 | + fixture.Repository.MakeACommit(); |
| 165 | + fixture.AssertFullSemver("2.1.0-foo.2", this.configuration); |
| 166 | + |
| 167 | + // pull request |
| 168 | + fixture.Repository.CreatePullRequestRef("feature/foo", MainBranch, normalise: true); |
| 169 | + fixture.AssertFullSemver("2.1.0-PullRequest0002.3", this.configuration); |
| 170 | + Commands.Checkout(fixture.Repository, MainBranch); |
| 171 | + fixture.Repository.MergeNoFF("feature/foo", Generate.SignatureNow()); |
| 172 | + fixture.AssertFullSemver("2.1.0", this.configuration); |
| 173 | + fixture.Repository.MakeATaggedCommit("2.1.0"); // must tag before pull of any hotfix otherwise hotfix stays at this version |
| 174 | + |
| 175 | + // hotfix branch |
| 176 | + var tag = fixture.Repository.Tags.Single(t => t.FriendlyName == "1.0.0"); |
| 177 | + var supportBranch = fixture.Repository.CreateBranch("support/1.0.0", (LibGit2Sharp.Commit)tag.Target); |
| 178 | + Commands.Checkout(fixture.Repository, supportBranch); |
| 179 | + fixture.AssertFullSemver("1.0.0", this.configuration); |
| 180 | + fixture.Repository.MakeACommit(); |
| 181 | + fixture.AssertFullSemver("1.0.1-beta.1", this.configuration); |
| 182 | + fixture.Repository.MakeACommit(); |
| 183 | + fixture.AssertFullSemver("1.0.1-beta.2", this.configuration); |
| 184 | + fixture.Repository.MakeATaggedCommit("1.0.1"); |
| 185 | + fixture.Repository.MakeACommit(); |
| 186 | + fixture.AssertFullSemver("1.0.2-beta.1", this.configuration); |
| 187 | + |
| 188 | + // pull request |
| 189 | + fixture.Repository.CreatePullRequestRef("support/1.0.0", MainBranch, 3, normalise: true); |
| 190 | + fixture.Repository.DumpGraph(); |
| 191 | + fixture.AssertFullSemver("2.1.1-PullRequest0003.6", this.configuration); |
| 192 | + Commands.Checkout(fixture.Repository, MainBranch); |
| 193 | + fixture.Repository.MergeNoFF("support/1.0.0", Generate.SignatureNow()); |
| 194 | + fixture.AssertFullSemver("2.1.1", this.configuration); |
| 195 | + } |
| 196 | + } |
| 197 | + |
| 198 | + [TestFixture(Description = "Failed test: Issue #2786, PR #2787, MainlineDevelopmentMode")] |
| 199 | + public class HotfixBranchesWithTaggedCommits |
| 200 | + { |
| 201 | + [Test] |
| 202 | + public void HotfixBranchesWithTaggedCommitsOnMain() |
| 203 | + { |
| 204 | + using var fixture = new EmptyRepositoryFixture(); |
| 205 | + var configuration = GitFlowConfigurationBuilder.New |
| 206 | + .WithVersioningMode(VersioningMode.Mainline) |
| 207 | + .WithIncrement(IncrementStrategy.Minor) |
| 208 | + .WithBranch(ConfigurationConstants.MainBranchKey, |
| 209 | + branchBuilder => branchBuilder |
| 210 | + .WithRegularExpression(ConfigurationConstants.MainBranchRegex) |
| 211 | + .WithSourceBranches(ConfigurationConstants.DevelopBranchKey, ConfigurationConstants.ReleaseBranchKey) |
| 212 | + .WithLabel("") |
| 213 | + .WithPreventIncrementOfMergedBranchVersion(true) |
| 214 | + .WithIncrement(IncrementStrategy.Minor) |
| 215 | + .WithIsMainline(true) |
| 216 | + .WithPreReleaseWeight(55000) |
| 217 | + ) |
| 218 | + .WithBranch(ConfigurationConstants.HotfixBranchKey, branchBuilder => branchBuilder.WithLabel("")) |
| 219 | + .Build(); |
| 220 | + |
| 221 | + fixture.Repository.MakeACommit("1"); |
| 222 | + fixture.MakeATaggedCommit("1.0.0"); |
| 223 | + |
| 224 | + fixture.MakeACommit(); // 1.1.0 |
| 225 | + fixture.AssertFullSemver("1.1.0", configuration); |
| 226 | + fixture.ApplyTag("1.1.0"); |
| 227 | + fixture.AssertFullSemver("1.1.0", configuration); |
| 228 | + |
| 229 | + fixture.BranchTo("hotfix/may"); |
| 230 | + fixture.AssertFullSemver("1.1.1", configuration); |
| 231 | + |
| 232 | + // Move main on |
| 233 | + fixture.Checkout(MainBranch); |
| 234 | + fixture.MakeACommit(); |
| 235 | + fixture.AssertFullSemver("1.2.0", configuration); |
| 236 | + |
| 237 | + // Continue on hotfix |
| 238 | + fixture.Checkout("hotfix/may"); |
| 239 | + fixture.MakeACommit(); // 1.2.1 |
| 240 | + fixture.AssertFullSemver("1.1.1", configuration); |
| 241 | + } |
| 242 | + |
| 243 | + [Test] |
| 244 | + public void HotfixBranchesWithTaggedCommitsOnHotfix() |
| 245 | + { |
| 246 | + using var fixture = new EmptyRepositoryFixture(); |
| 247 | + var configuration = GitFlowConfigurationBuilder.New |
| 248 | + .WithVersioningMode(VersioningMode.Mainline) |
| 249 | + .WithIncrement(IncrementStrategy.Minor) |
| 250 | + .WithBranch(ConfigurationConstants.MainBranchKey, |
| 251 | + branchBuilder => branchBuilder |
| 252 | + .WithRegularExpression(ConfigurationConstants.MainBranchRegex) |
| 253 | + .WithSourceBranches(ConfigurationConstants.DevelopBranchKey, ConfigurationConstants.ReleaseBranchKey) |
| 254 | + .WithLabel("") |
| 255 | + .WithPreventIncrementOfMergedBranchVersion(true) |
| 256 | + .WithIncrement(IncrementStrategy.Minor) |
| 257 | + .WithIsMainline(true) |
| 258 | + .WithPreReleaseWeight(55000) |
| 259 | + ) |
| 260 | + .WithBranch(ConfigurationConstants.HotfixBranchKey, branchBuilder => branchBuilder.WithLabel("")) |
| 261 | + .Build(); |
| 262 | + |
| 263 | + fixture.Repository.MakeACommit("1"); |
| 264 | + fixture.MakeATaggedCommit("1.0.0"); |
| 265 | + |
| 266 | + fixture.MakeACommit(); // 1.1.0 |
| 267 | + fixture.AssertFullSemver("1.1.0", configuration); |
| 268 | + fixture.ApplyTag("1.1.0"); |
| 269 | + fixture.AssertFullSemver("1.1.0", configuration); |
| 270 | + fixture.MakeACommit(); // 1.2.0 |
| 271 | + fixture.AssertFullSemver("1.2.0", configuration); |
| 272 | + |
| 273 | + fixture.BranchTo("hotfix/may"); |
| 274 | + fixture.AssertFullSemver("1.2.1", configuration); |
| 275 | + |
| 276 | + // Move main on |
| 277 | + fixture.Checkout(MainBranch); |
| 278 | + fixture.MakeACommit(); |
| 279 | + fixture.AssertFullSemver("1.3.0", configuration); |
| 280 | + |
| 281 | + // Continue on hotfix |
| 282 | + fixture.Checkout("hotfix/may"); |
| 283 | + fixture.MakeACommit(); // 1.2.1 |
| 284 | + fixture.MakeATaggedCommit("1.2.2"); |
| 285 | + fixture.MakeACommit(); // 1.2.3 |
| 286 | + fixture.AssertFullSemver("1.2.3", configuration); |
| 287 | + } |
| 288 | + } |
| 289 | +} |
0 commit comments