diff --git a/src/GitVersion.Core.Tests/IntegrationTests/FailingTests.cs b/src/GitVersion.Core.Tests/IntegrationTests/FailingTests.cs new file mode 100644 index 0000000000..99dc870a6a --- /dev/null +++ b/src/GitVersion.Core.Tests/IntegrationTests/FailingTests.cs @@ -0,0 +1,119 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests.Helpers; +using GitVersion.Extensions; +using GitVersion.VersionCalculation; +using LibGit2Sharp; + +namespace GitVersion.Core.Tests.IntegrationTests; + +[TestFixture] +public class FailingTests : TestBase +{ + [Test(Description = "Failed test: Issue #1255, PR #1600, DevelopScenarios")] + public void ShouldProvideTheCorrectVersionEvenIfPreReleaseLabelExistsInTheGitTagDevelop() + { + using var fixture = new EmptyRepositoryFixture(); + fixture.Repository.MakeACommit(); + fixture.ApplyTag("1.0.0-oreo.1"); + fixture.BranchTo("develop"); + fixture.Repository.MakeACommit(); + fixture.AssertFullSemver("1.1.0-alpha.1"); + } + + [Test(Description = "Failed test: Issue #1255, PR #1600, MainScenarios")] + public void ShouldProvideTheCorrectVersionEvenIfPreReleaseLabelExistsInTheGitTagMain() + { + var configuration = GitFlowConfigurationBuilder.New + .WithSemanticVersionFormat(SemanticVersionFormat.Loose) + .WithNextVersion("5.0") + .WithBranch("main", + branchBuilder => branchBuilder.WithLabel("beta") + .WithIncrement(IncrementStrategy.Patch) + .WithVersioningMode(VersioningMode.ContinuousDeployment)) + .Build(); + + using EmptyRepositoryFixture fixture = new("main"); + fixture.Repository.MakeACommit(); + fixture.AssertFullSemver("5.0.0-beta.0", configuration); // why not "5.0.0-beta.1"? + fixture.Repository.MakeACommit(); + fixture.AssertFullSemver("5.0.0-beta.1", configuration); + fixture.Repository.MakeATaggedCommit("v5.0.0-rc.1"); + fixture.AssertFullSemver("5.0.0-rc.1", configuration); + fixture.Repository.MakeACommit(); + 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" + } + + [Test(Description = "Failed test: Issue #1844, PR #1845, VersionBumpingScenarios")] + public void AppliedPrereleaseTagAfterBranchTagCausesVersionBump() + { + var configuration = GitFlowConfigurationBuilder.New + .WithBranch("main", + branchBuilder => branchBuilder.WithLabel("pre") + .WithSourceBranches(ArraySegment.Empty) + .WithVersioningMode(VersioningMode.ContinuousDeployment)) + .Build(); + + using var fixture = new EmptyRepositoryFixture(); + fixture.Repository.MakeACommit(); + fixture.Repository.MakeATaggedCommit("1.0.0-rc"); + fixture.Repository.MakeACommit(); + + fixture.AssertFullSemver("1.0.1-pre.1", configuration); + } + + [Test(Description = "Failed test: Issue #2034, PR #2059, MainlineDevelopmentMode")] + public void MergingMasterBranchToDevelopWithInheritIncrementShouldIncrementDevelopPatch() + { + var configuration = GitFlowConfigurationBuilder.New + .WithAssemblyVersioningScheme(AssemblyVersioningScheme.MajorMinorPatch) + .WithVersioningMode(VersioningMode.Mainline) + .WithBranch("main", branchBuilder => branchBuilder.WithIncrement(IncrementStrategy.Patch)) + .WithBranch("develop", branchBuilder => branchBuilder.WithIncrement(IncrementStrategy.Inherit)) + .Build(); + + using var fixture = new EmptyRepositoryFixture(); + fixture.MakeACommit("initial in main"); + fixture.AssertFullSemver("0.1.0", configuration); + fixture.MakeACommit("main change"); + fixture.AssertFullSemver("0.1.1", configuration); + + fixture.BranchTo("develop"); + fixture.AssertFullSemver("0.1.2-alpha.0", configuration); + fixture.MakeACommit("develop change"); + fixture.AssertFullSemver("0.1.2-alpha.1", configuration); + + fixture.Checkout("main"); + fixture.MakeACommit("main hotfix"); + fixture.AssertFullSemver("0.1.2", configuration); + + fixture.Checkout("develop"); + fixture.MergeNoFF("master"); + fixture.AssertFullSemver("0.1.3-alpha.1", configuration); + } + + [Test(Description = "Failed test: Issue #2693, PR #2696, HotfixBranchScenarios")] + public void VersionNumberInHotfixBranchShouldBeConsideredWhenPreventIncrementOfMergedBranchVersion() + { + var configuration = GitFlowConfigurationBuilder.New + .WithAssemblyVersioningScheme(AssemblyVersioningScheme.MajorMinorPatchTag) + .WithAssemblyFileVersioningFormat("{MajorMinorPatch}.0") + .WithVersioningMode(VersioningMode.ContinuousDeployment) + .WithBranch("hotfix", branchBuilder => branchBuilder + .WithPreventIncrementOfMergedBranchVersion(true) + .WithRegularExpression("r^(origin/)?hotfix[/-]") + ) + .Build(); + + const string HotfixBranch = "hotfix/1.1.1"; + const string ReleaseBranch = "release/1.1.0"; + + using var fixture = new BaseGitFlowRepositoryFixture("1.0.0"); + Commands.Checkout(fixture.Repository, fixture.Repository.CreateBranch(ReleaseBranch)); + fixture.MakeACommit(); + Commands.Checkout(fixture.Repository, MainBranch); + fixture.MergeNoFF(ReleaseBranch); + fixture.Repository.CreateBranch(HotfixBranch); + fixture.Repository.MakeACommit(); + fixture.AssertFullSemver("1.1.1-ci.1", configuration); + } +}