diff --git a/src/GitVersion.Core.Tests/IntegrationTests/HotfixBranchScenarios.cs b/src/GitVersion.Core.Tests/IntegrationTests/HotfixBranchScenarios.cs index eab63072d9..7582100d11 100644 --- a/src/GitVersion.Core.Tests/IntegrationTests/HotfixBranchScenarios.cs +++ b/src/GitVersion.Core.Tests/IntegrationTests/HotfixBranchScenarios.cs @@ -19,7 +19,7 @@ public void PatchLatestReleaseExample() using var fixture = new BaseGitFlowRepositoryFixture("1.2.0"); // create hotfix Commands.Checkout(fixture.Repository, MainBranch); - Commands.Checkout(fixture.Repository, fixture.Repository.CreateBranch("hotfix-1.2.1")); + Commands.Checkout(fixture.Repository, fixture.Repository.CreateBranch("hotfix/1.2.1")); fixture.Repository.MakeACommit(); fixture.AssertFullSemver("1.2.1-beta.1+1"); @@ -33,7 +33,7 @@ public void PatchLatestReleaseExample() // Merge hotfix branch to main Commands.Checkout(fixture.Repository, MainBranch); - fixture.Repository.MergeNoFF("hotfix-1.2.1", Generate.SignatureNow()); + fixture.Repository.MergeNoFF("hotfix/1.2.1", Generate.SignatureNow()); fixture.AssertFullSemver("1.2.1+4"); fixture.Repository.ApplyTag("1.2.1"); @@ -43,7 +43,7 @@ public void PatchLatestReleaseExample() Commands.Checkout(fixture.Repository, "develop"); fixture.AssertFullSemver("1.3.0-alpha.1"); - fixture.Repository.MergeNoFF("hotfix-1.2.1", Generate.SignatureNow()); + fixture.Repository.MergeNoFF("hotfix/1.2.1", Generate.SignatureNow()); fixture.AssertFullSemver("1.3.0-alpha.5"); } @@ -227,5 +227,146 @@ public void FeatureOnHotfixFeatureBranchNotDeleted() fixture.AssertFullSemver("4.5.1-beta.2", config); } + [Test] + public void HotfixMergeIncrementsVersionWithModeContinuousDeployment() + { + var config = new Config + { + AssemblyVersioningScheme = AssemblyVersioningScheme.MajorMinorPatchTag, + VersioningMode = VersioningMode.ContinuousDeployment + }; + + using var fixture = new EmptyRepositoryFixture(); + + // initialize gitflow + + const string devBranch = "develop"; + + fixture.Repository.MakeACommit("setup repo"); + fixture.Repository.CreateBranch(devBranch); + Commands.Checkout(fixture.Repository, devBranch); + + // make some changes on dev + + fixture.Repository.MakeACommit("add stuff"); + fixture.Repository.MakeACommit("add more stuff"); + + // start a release + + const string releaseBranch = "release/1.0"; + + fixture.Repository.CreateBranch(releaseBranch); + Commands.Checkout(fixture.Repository, releaseBranch); + fixture.Repository.MakeACommit("fix some minor thing"); + + fixture.AssertFullSemver("1.0.0-beta.1", config); + + Commands.Checkout(fixture.Repository, MainBranch); + fixture.Repository.MergeNoFF(releaseBranch, Generate.SignatureNow()); + + fixture.AssertFullSemver("1.0.0-ci.0", config); + fixture.ApplyTag("1.0"); + fixture.AssertFullSemver("1.0.0", config); + + // start first hotfix + + const string hotfixBranch = "hotfix/something-important"; + + fixture.Repository.CreateBranch(hotfixBranch); + fixture.Repository.MakeACommit("fix the important issue"); + // fixture.AssertFullSemver("1.0.1-beta.1"); // FAILS, not sure if hotfixes should have beta tag + fixture.AssertFullSemver("1.0.1-ci.1", config); // PASSES + fixture.Repository.MakeACommit("fix something else"); + // fixture.AssertFullSemver("1.0.1-beta.2"); // FAILS, not sure if hotfixes should have beta tag + fixture.AssertFullSemver("1.0.1-ci.2", config); // PASSES + + Commands.Checkout(fixture.Repository, MainBranch); + fixture.Repository.MergeNoFF(hotfixBranch, Generate.SignatureNow()); + + fixture.AssertFullSemver("1.0.1-ci.2", config); + + // start second hotfix + + const string hotfix2Branch = "hotfix/another-important-thing"; + + fixture.Repository.CreateBranch(hotfix2Branch); + fixture.Repository.MakeACommit("fix the new issue"); + // fixture.AssertFullSemver("1.0.2-beta.1"); // FAILS, not sure if hotfixes should have beta tag + fixture.AssertFullSemver("1.0.2-ci.1", config); // FAILS, version is 1.0.1-ci.3 + + Commands.Checkout(fixture.Repository, MainBranch); + fixture.Repository.MergeNoFF(hotfix2Branch, Generate.SignatureNow()); + + fixture.AssertFullSemver("1.0.2-ci.1", config); // FAILS, version is 1.0.1-ci.3 + } + + [Test] + public void HotfixMergeIncrementsVersionWithDefaultConfig() + { + var config = new Config(); + + using var fixture = new EmptyRepositoryFixture(); + + // initialize gitflow + + const string devBranch = "develop"; + + fixture.Repository.MakeACommit("setup repo"); + fixture.Repository.CreateBranch(devBranch); + Commands.Checkout(fixture.Repository, devBranch); + + // make some changes on dev + + fixture.Repository.MakeACommit("add stuff"); + fixture.Repository.MakeACommit("add more stuff"); + + // start a release + + const string releaseBranch = "release/1.0"; + + fixture.Repository.CreateBranch(releaseBranch); + Commands.Checkout(fixture.Repository, releaseBranch); + fixture.Repository.MakeACommit("fix some minor thing"); + + fixture.AssertFullSemver("1.0.0-beta.1+1", config); + + Commands.Checkout(fixture.Repository, MainBranch); + fixture.Repository.MergeNoFF(releaseBranch, Generate.SignatureNow()); + + fixture.AssertFullSemver("1.0.0+0", config); + fixture.ApplyTag("1.0"); + fixture.AssertFullSemver("1.0.0", config); + + // start first hotfix + + const string hotfixBranch = "hotfix/something-important"; + + fixture.Repository.CreateBranch(hotfixBranch); + fixture.Repository.MakeACommit("fix the important issue"); + // fixture.AssertFullSemver("1.0.1-beta.1+1", config); // FAILS, not sure if hotfixes should have beta tag + fixture.AssertFullSemver("1.0.1+1", config); + fixture.Repository.MakeACommit("fix something else"); + // fixture.AssertFullSemver("1.0.1-beta.2+2", config); // FAILS, not sure if hotfixes should have beta tag + fixture.AssertFullSemver("1.0.1+2", config); + + Commands.Checkout(fixture.Repository, MainBranch); + fixture.Repository.MergeNoFF(hotfixBranch, Generate.SignatureNow()); + + fixture.AssertFullSemver("1.0.1+2", config); + + // start second hotfix + + const string hotfix2Branch = "hotfix/another-important-thing"; + + fixture.Repository.CreateBranch(hotfix2Branch); + fixture.Repository.MakeACommit("fix the new issue"); + // fixture.AssertFullSemver("1.0.2-beta.1+1", config); // FAILS, not sure if hotfixes should have beta tag + fixture.AssertFullSemver("1.0.2+1", config); // FAILS, version is 1.0.1+3 + + Commands.Checkout(fixture.Repository, MainBranch); + fixture.Repository.MergeNoFF(hotfix2Branch, Generate.SignatureNow()); + + fixture.AssertFullSemver("1.0.2+1", config); // FAILS, version is 1.0.1+3 + } } }