diff --git a/docs/input/docs/reference/configuration.md b/docs/input/docs/reference/configuration.md index da84070111..99b3aba154 100644 --- a/docs/input/docs/reference/configuration.md +++ b/docs/input/docs/reference/configuration.md @@ -105,7 +105,7 @@ branches: of-merged-branch: true when-current-commit-tagged: false track-merge-target: false - regex: ^releases?[/-] + regex: ^releases?[/-](?.+) source-branches: - develop - main @@ -153,7 +153,7 @@ branches: increment: Inherit prevent-increment: when-current-commit-tagged: false - regex: ^hotfix(es)?[/-] + regex: ^hotfix(es)?[/-](?.+) source-branches: - release - main @@ -168,7 +168,7 @@ branches: prevent-increment: of-merged-branch: true track-merge-target: false - regex: ^support[/-] + regex: ^support[/-](?.+) source-branches: - main is-source-branch-for: [] @@ -209,7 +209,6 @@ is-source-branch-for: [] tracks-release-branches: false is-release-branch: false is-main-branch: false - ``` The supported built-in configuration for the `GitHubFlow` workflow (`workflow: GitHubFlow/v1`) looks like: @@ -257,7 +256,7 @@ branches: of-merged-branch: true when-current-commit-tagged: false track-merge-target: false - regex: ^releases?[/-] + regex: ^releases?[/-](?.+) source-branches: - main - release @@ -370,7 +369,7 @@ branches: - main pre-release-weight: 30000 pull-request: - mode: ManualDeployment + mode: ContinuousDelivery label: PullRequest increment: Inherit label-number-pattern: '[/-](?\d+)' @@ -379,17 +378,16 @@ branches: - main pre-release-weight: 30000 unknown: - mode: ManualDeployment - increment: Inherit + increment: Patch regex: (?.+) + prevent-increment: + when-current-commit-tagged: false source-branches: - main - - feature - - hotfix - - pull-request + pre-release-weight: 30000 ignore: sha: [] -mode: ManualDeployment +mode: ContinuousDelivery label: '{BranchName}' increment: Inherit prevent-increment: @@ -403,6 +401,7 @@ regex: '' tracks-release-branches: false is-release-branch: false is-main-branch: false + ``` The details of the available options are as follows: diff --git a/src/GitVersion.Configuration.Tests/Configuration/ConfigurationProviderTests.CanWriteOutEffectiveConfiguration.approved.txt b/src/GitVersion.Configuration.Tests/Configuration/ConfigurationProviderTests.CanWriteOutEffectiveConfiguration.approved.txt index a043a75634..83c233ec89 100644 --- a/src/GitVersion.Configuration.Tests/Configuration/ConfigurationProviderTests.CanWriteOutEffectiveConfiguration.approved.txt +++ b/src/GitVersion.Configuration.Tests/Configuration/ConfigurationProviderTests.CanWriteOutEffectiveConfiguration.approved.txt @@ -54,7 +54,7 @@ branches: of-merged-branch: true when-current-commit-tagged: false track-merge-target: false - regex: ^releases?[/-] + regex: ^releases?[/-](?.+) source-branches: - develop - main @@ -102,7 +102,7 @@ branches: increment: Inherit prevent-increment: when-current-commit-tagged: false - regex: ^hotfix(es)?[/-] + regex: ^hotfix(es)?[/-](?.+) source-branches: - release - main @@ -117,7 +117,7 @@ branches: prevent-increment: of-merged-branch: true track-merge-target: false - regex: ^support[/-] + regex: ^support[/-](?.+) source-branches: - main is-source-branch-for: [] diff --git a/src/GitVersion.Configuration/SupportedWorkflows/GitFlow/v1.yml b/src/GitVersion.Configuration/SupportedWorkflows/GitFlow/v1.yml index a043a75634..83c233ec89 100644 --- a/src/GitVersion.Configuration/SupportedWorkflows/GitFlow/v1.yml +++ b/src/GitVersion.Configuration/SupportedWorkflows/GitFlow/v1.yml @@ -54,7 +54,7 @@ branches: of-merged-branch: true when-current-commit-tagged: false track-merge-target: false - regex: ^releases?[/-] + regex: ^releases?[/-](?.+) source-branches: - develop - main @@ -102,7 +102,7 @@ branches: increment: Inherit prevent-increment: when-current-commit-tagged: false - regex: ^hotfix(es)?[/-] + regex: ^hotfix(es)?[/-](?.+) source-branches: - release - main @@ -117,7 +117,7 @@ branches: prevent-increment: of-merged-branch: true track-merge-target: false - regex: ^support[/-] + regex: ^support[/-](?.+) source-branches: - main is-source-branch-for: [] diff --git a/src/GitVersion.Configuration/SupportedWorkflows/GitHubFlow/v1.yml b/src/GitVersion.Configuration/SupportedWorkflows/GitHubFlow/v1.yml index 18dea546dd..48e1d6aabc 100644 --- a/src/GitVersion.Configuration/SupportedWorkflows/GitHubFlow/v1.yml +++ b/src/GitVersion.Configuration/SupportedWorkflows/GitHubFlow/v1.yml @@ -40,7 +40,7 @@ branches: of-merged-branch: true when-current-commit-tagged: false track-merge-target: false - regex: ^releases?[/-] + regex: ^releases?[/-](?.+) source-branches: - main - release diff --git a/src/GitVersion.Configuration/SupportedWorkflows/TrunkBased/v1.yml b/src/GitVersion.Configuration/SupportedWorkflows/TrunkBased/v1.yml index bb225073de..023be21f85 100644 --- a/src/GitVersion.Configuration/SupportedWorkflows/TrunkBased/v1.yml +++ b/src/GitVersion.Configuration/SupportedWorkflows/TrunkBased/v1.yml @@ -45,7 +45,7 @@ branches: - main pre-release-weight: 30000 pull-request: - mode: ManualDeployment + mode: ContinuousDelivery label: PullRequest increment: Inherit label-number-pattern: '[/-](?\d+)' @@ -54,17 +54,16 @@ branches: - main pre-release-weight: 30000 unknown: - mode: ManualDeployment - increment: Inherit + increment: Patch regex: (?.+) + prevent-increment: + when-current-commit-tagged: false source-branches: - main - - feature - - hotfix - - pull-request + pre-release-weight: 30000 ignore: sha: [] -mode: ManualDeployment +mode: ContinuousDelivery label: '{BranchName}' increment: Inherit prevent-increment: diff --git a/src/GitVersion.Configuration/TrunkBasedConfigurationBuilder.cs b/src/GitVersion.Configuration/TrunkBasedConfigurationBuilder.cs index a522d694a7..1a17da8ae4 100644 --- a/src/GitVersion.Configuration/TrunkBasedConfigurationBuilder.cs +++ b/src/GitVersion.Configuration/TrunkBasedConfigurationBuilder.cs @@ -26,7 +26,7 @@ private TrunkBasedConfigurationBuilder() VersionInBranchPattern = ConfigurationConstants.DefaultVersionInBranchPattern, TagPreReleaseWeight = ConfigurationConstants.DefaultTagPreReleaseWeight, UpdateBuildNumber = ConfigurationConstants.DefaultUpdateBuildNumber, - DeploymentMode = DeploymentMode.ManualDeployment, + DeploymentMode = DeploymentMode.ContinuousDelivery, RegularExpression = string.Empty, Label = ConfigurationConstants.BranchNamePlaceholder, Increment = IncrementStrategy.Inherit, @@ -96,7 +96,7 @@ private TrunkBasedConfigurationBuilder() { Increment = IncrementStrategy.Inherit, RegularExpression = PullRequestBranch.RegexPattern, - DeploymentMode = DeploymentMode.ManualDeployment, + DeploymentMode = DeploymentMode.ContinuousDelivery, SourceBranches = [ this.MainBranch.Name @@ -108,15 +108,17 @@ private TrunkBasedConfigurationBuilder() WithBranch(UnknownBranch.Name).WithConfiguration(new BranchConfiguration { + Increment = IncrementStrategy.Patch, RegularExpression = UnknownBranch.RegexPattern, - DeploymentMode = DeploymentMode.ManualDeployment, - Increment = IncrementStrategy.Inherit, SourceBranches = [ - this.MainBranch.Name, - this.FeatureBranch.Name, - this.PullRequestBranch.Name - ] + this.MainBranch.Name + ], + PreventIncrement = new PreventIncrementConfiguration() + { + WhenCurrentCommitTagged = false + }, + PreReleaseWeight = 30000 }); } } diff --git a/src/GitVersion.Core.Tests/Core/RepositoryStoreTests.cs b/src/GitVersion.Core.Tests/Core/RepositoryStoreTests.cs index 1597350f97..00ed164fc6 100644 --- a/src/GitVersion.Core.Tests/Core/RepositoryStoreTests.cs +++ b/src/GitVersion.Core.Tests/Core/RepositoryStoreTests.cs @@ -213,7 +213,6 @@ public void GetBranchesContainingCommitThrowsDirectlyOnNullCommit() } [Test] - [Ignore("Needs more investigations.")] public void FindCommitBranchWasBranchedFromShouldReturnNullIfTheRemoteIsTheOnlySource() { using var fixture = new RemoteRepositoryFixture(); diff --git a/src/GitVersion.Core.Tests/IntegrationTests/ReleaseBranchScenarios.cs b/src/GitVersion.Core.Tests/IntegrationTests/ReleaseBranchScenarios.cs index f8a9d103a2..4684491768 100644 --- a/src/GitVersion.Core.Tests/IntegrationTests/ReleaseBranchScenarios.cs +++ b/src/GitVersion.Core.Tests/IntegrationTests/ReleaseBranchScenarios.cs @@ -452,9 +452,12 @@ public void CommitBeetweenMergeReleaseToDevelopShouldNotResetCount() } [Test] - [Ignore("Needs investigation")] public void ReleaseBranchShouldUseBranchNameVersionDespiteBumpInPreviousCommit() { + var configuration = GitFlowConfigurationBuilder.New + .WithSemanticVersionFormat(SemanticVersionFormat.Loose) + .Build(); + using var fixture = new EmptyRepositoryFixture(); fixture.Repository.MakeATaggedCommit("1.0"); fixture.Repository.MakeACommit("+semver:major"); @@ -462,7 +465,7 @@ public void ReleaseBranchShouldUseBranchNameVersionDespiteBumpInPreviousCommit() fixture.BranchTo("release/2.0"); - fixture.AssertFullSemver("2.0.0-beta.1+2"); + fixture.AssertFullSemver("2.0.0-beta.1+2", configuration); } [Test] diff --git a/src/GitVersion.Core.Tests/IntegrationTests/TrunkBasedDevelopmentScenarios.cs b/src/GitVersion.Core.Tests/IntegrationTests/TrunkBasedDevelopmentScenarios.cs index 80be294775..e3998d6179 100644 --- a/src/GitVersion.Core.Tests/IntegrationTests/TrunkBasedDevelopmentScenarios.cs +++ b/src/GitVersion.Core.Tests/IntegrationTests/TrunkBasedDevelopmentScenarios.cs @@ -36,27 +36,6 @@ private static GitFlowConfigurationBuilder GetConfigurationBuilder() => GitFlowC .WithSourceBranches("main") ); - [Test] - [Ignore("Support of multiple tunks are not implemented at the moment.")] - public void VerifyNonMainMainlineVersionIdenticalAsMain() - { - var configuration = GetConfigurationBuilder().Build(); - - using var fixture = new EmptyRepositoryFixture(); - fixture.Repository.MakeACommit("1"); - - fixture.BranchTo("feature/foo", "foo"); - fixture.MakeACommit("2 +semver: major"); - fixture.Checkout(MainBranch); - fixture.MergeNoFF("feature/foo"); - - fixture.AssertFullSemver("1.0.0", configuration); - - fixture.BranchTo("support/1.0", "support"); - - fixture.AssertFullSemver("1.0.0", configuration); - } - [Test] public void MergedFeatureBranchesToMainImpliesRelease() { diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitBTaggedAsStable.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitBTaggedAsStable.cs index ffcae22f52..348fc74350 100644 --- a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitBTaggedAsStable.cs +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitBTaggedAsStable.cs @@ -148,7 +148,6 @@ public string GetVersionWithNoLabelOnMain( return fixture!.GetVersion(trunkBased).FullSemVer; } - [Ignore("Enable if WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) feature has been implemented!")] [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] @@ -232,11 +231,11 @@ public string GetVersionWithNoLabelOnMain( [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] - public string GetVersionWithNoLabelOnMainAndTakeAlwaysIncrementedVersion( + public string GetVersionWithNoLabelAndPreventIncrementWhenCurrentCommitTaggedFalseOnMain( IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) { IGitVersionConfiguration trunkBased = TrunkBasedBuilder - //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) + .WithPreventIncrementWhenCurrentCommitTagged(false) .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) .Build(); @@ -358,7 +357,6 @@ public string GetVersionWithEmptyLabelOnMain( return fixture!.GetVersion(trunkBased).FullSemVer; } - [Ignore("Enable if WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) feature has been implemented!")] [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] @@ -442,11 +440,11 @@ public string GetVersionWithEmptyLabelOnMain( [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] - public string GetVersionWithEmptyLabelOnMainAndTakeAlwaysIncrementedVersion( + public string GetVersionWithEmptyLabelAndPreventIncrementWhenCurrentCommitTaggedFalseOnMain( IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) { IGitVersionConfiguration trunkBased = TrunkBasedBuilder - //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) + .WithPreventIncrementWhenCurrentCommitTagged(false) .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) .Build(); @@ -568,7 +566,6 @@ public string GetVersionWithLabelFooOnMain( return fixture!.GetVersion(trunkBased).FullSemVer; } - [Ignore("Enable if WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) feature has been implemented!")] [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] @@ -652,11 +649,11 @@ public string GetVersionWithLabelFooOnMain( [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] - public string GetVersionWithLabelFooOnMainAndTakeAlwaysIncrementedVersion( + public string GetVersionWithLabelFooAndPreventIncrementWhenCurrentCommitTaggedFalseOnMain( IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) { IGitVersionConfiguration trunkBased = TrunkBasedBuilder - //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) + .WithPreventIncrementWhenCurrentCommitTagged(false) .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) .Build(); @@ -778,7 +775,6 @@ public string GetVersionWithLabelBarOnMain( return fixture!.GetVersion(trunkBased).FullSemVer; } - [Ignore("Enable if WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) feature has been implemented!")] [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] @@ -862,11 +858,11 @@ public string GetVersionWithLabelBarOnMain( [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] - public string GetVersionWithLabelBarOnMainAndTakeAlwaysIncrementedVersion( + public string GetVersionWithLabelBarAndPreventIncrementWhenCurrentCommitTaggedFalseOnMain( IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) { IGitVersionConfiguration trunkBased = TrunkBasedBuilder - //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) + .WithPreventIncrementWhenCurrentCommitTagged(false) .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) .Build(); diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitTaggedAsPreRelease.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitTaggedAsPreRelease.cs index ba140ea4e1..4040ad96dd 100644 --- a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitTaggedAsPreRelease.cs +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitTaggedAsPreRelease.cs @@ -58,7 +58,6 @@ public string GetVersion(IncrementStrategy increment, string? label) return fixture!.GetVersion(trunkBased).FullSemVer; } - [Ignore("Enable if WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) feature has been implemented!")] [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-5+0")] [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-5+0")] [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-5+0")] @@ -78,10 +77,10 @@ public string GetVersion(IncrementStrategy increment, string? label) [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] [TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] [TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] - public string GetVersionWithTakeAlwaysIncrementedVersion(IncrementStrategy increment, string? label) + public string GetVersionWithPreventIncrementWhenCurrentCommitTaggedFalse(IncrementStrategy increment, string? label) { IGitVersionConfiguration trunkBased = TrunkBasedBuilder - //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) + .WithPreventIncrementWhenCurrentCommitTagged(false) .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) .Build(); diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitTaggedAsPreReleaseBar.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitTaggedAsPreReleaseBar.cs index 8793e188e8..156234a55a 100644 --- a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitTaggedAsPreReleaseBar.cs +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitTaggedAsPreReleaseBar.cs @@ -58,11 +58,10 @@ public string GetVersion(IncrementStrategy increment, string? label) return fixture!.GetVersion(trunkBased).FullSemVer; } - [Ignore("Enable if WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) feature has been implemented!")] - [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar")] - [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-bar")] - [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar")] - [TestCase(IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar+0")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-bar+0")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar+0")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar+0")] [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] @@ -74,14 +73,14 @@ public string GetVersion(IncrementStrategy increment, string? label) [TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] [TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] - [TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar")] - [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-bar")] - [TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar")] - [TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar")] - public string GetVersionWithTakeAlwaysIncrementedVersion(IncrementStrategy increment, string? label) + [TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+0")] + [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-bar+0")] + [TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar+0")] + [TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar+0")] + public string GetVersionWithPreventIncrementWhenCurrentCommitTaggedFalse(IncrementStrategy increment, string? label) { IGitVersionConfiguration trunkBased = TrunkBasedBuilder - //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) + .WithPreventIncrementWhenCurrentCommitTagged(false) .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) .Build(); diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitTaggedAsPreReleaseFoo.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitTaggedAsPreReleaseFoo.cs index 926d94fd3c..ea3a375d5f 100644 --- a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitTaggedAsPreReleaseFoo.cs +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitTaggedAsPreReleaseFoo.cs @@ -58,7 +58,6 @@ public string GetVersion(IncrementStrategy increment, string? label) return fixture!.GetVersion(trunkBased).FullSemVer; } - [Ignore("Enable if WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) feature has been implemented!")] [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.5+0")] [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.5+0")] [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.5+0")] @@ -78,10 +77,10 @@ public string GetVersion(IncrementStrategy increment, string? label) [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] [TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] [TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] - public string GetVersionWithTakeAlwaysIncrementedVersion(IncrementStrategy increment, string? label) + public string GetVersionWithPreventIncrementWhenCurrentCommitTaggedFalse(IncrementStrategy increment, string? label) { IGitVersionConfiguration trunkBased = TrunkBasedBuilder - //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) + .WithPreventIncrementWhenCurrentCommitTagged(false) .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) .Build(); diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitTaggedAsStable.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitTaggedAsStable.cs index 40fe52b045..a75ab7755e 100644 --- a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitTaggedAsStable.cs +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitTaggedAsStable.cs @@ -58,7 +58,6 @@ public string GetVersion(IncrementStrategy increment, string? label) return fixture!.GetVersion(trunkBased).FullSemVer; } - [Ignore("Enable if WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) feature has been implemented!")] [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+0")] [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+0")] [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] @@ -78,10 +77,10 @@ public string GetVersion(IncrementStrategy increment, string? label) [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] [TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] [TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] - public string GetVersionWithTakeAlwaysIncrementedVersion(IncrementStrategy increment, string? label) + public string GetVersionWithPreventIncrementWhenCurrentCommitTaggedFalse(IncrementStrategy increment, string? label) { IGitVersionConfiguration trunkBased = TrunkBasedBuilder - //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) + .WithPreventIncrementWhenCurrentCommitTagged(false) .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) .Build(); diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitTaggedAsPreRelease.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitTaggedAsPreRelease.cs index fe27b519c3..58b7310910 100644 --- a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitTaggedAsPreRelease.cs +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitTaggedAsPreRelease.cs @@ -145,7 +145,6 @@ public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, Inc return fixture!.GetVersion(trunkBased).FullSemVer; } - [Ignore("Enable if WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) feature has been implemented!")] [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-5+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] @@ -249,14 +248,14 @@ public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, Inc [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] - public string GetVersionWithNoLabelOnMainAndTakeAlwaysIncrementedVersionOnFeature( + public string GetVersionWithNoLabelAndPreventIncrementWhenCurrentCommitTaggedFalseOnMain( IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) { IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithPreventIncrementWhenCurrentCommitTagged(false) .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) - .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label) - //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) - ).Build(); + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); return fixture!.GetVersion(trunkBased).FullSemVer; } @@ -374,7 +373,6 @@ public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, return fixture!.GetVersion(trunkBased).FullSemVer; } - [Ignore("Enable if WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) feature has been implemented!")] [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-5+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] @@ -478,14 +476,14 @@ public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] - public string GetVersionWithEmptyLabelOnMainAndTakeAlwaysIncrementedVersionOnFeature( + public string GetVersionWithEmptyLabelAndPreventIncrementWhenCurrentCommitTaggedFalseOnMain( IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) { IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithPreventIncrementWhenCurrentCommitTagged(false) .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) - .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label) - //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) - ).Build(); + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); return fixture!.GetVersion(trunkBased).FullSemVer; } @@ -603,7 +601,6 @@ public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, In return fixture!.GetVersion(trunkBased).FullSemVer; } - [Ignore("Enable if WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) feature has been implemented!")] [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.2+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] @@ -707,14 +704,14 @@ public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, In [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] - public string GetVersionWithLabelFooOnMainAndTakeAlwaysIncrementedVersionOnFeature( + public string GetVersionWithLabelFooAndPreventIncrementWhenCurrentCommitTaggedFalseOnMain( IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) { IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithPreventIncrementWhenCurrentCommitTagged(false) .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) - .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label) - //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) - ).Build(); + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); return fixture!.GetVersion(trunkBased).FullSemVer; } @@ -832,7 +829,6 @@ public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, In return fixture!.GetVersion(trunkBased).FullSemVer; } - [Ignore("Enable if WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) feature has been implemented!")] [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.2+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar.1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+0")] @@ -936,14 +932,14 @@ public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, In [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] - public string GetVersionWithLabelBarOnMainAndTakeAlwaysIncrementedVersionOnFeature( + public string GetVersionWithLabelBarAndPreventIncrementWhenCurrentCommitTaggedFalseOnMain( IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) { IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithPreventIncrementWhenCurrentCommitTagged(false) .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) - .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label) - //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) - ).Build(); + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); return fixture!.GetVersion(trunkBased).FullSemVer; } diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitTaggedAsPreReleaseBar.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitTaggedAsPreReleaseBar.cs index 7d6dbda2a5..77034f847e 100644 --- a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitTaggedAsPreReleaseBar.cs +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitTaggedAsPreReleaseBar.cs @@ -145,12 +145,11 @@ public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, Inc return fixture!.GetVersion(trunkBased).FullSemVer; } - [Ignore("Enable if WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) feature has been implemented!")] - [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar+0")] - [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] @@ -161,18 +160,18 @@ public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, Inc [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+0")] - [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar+0")] - [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+0")] - [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar+0")] [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar+0")] [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar+0")] [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar+0")] @@ -187,7 +186,7 @@ public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, Inc [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+0")] [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+0")] [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+0")] - [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+0")] [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar+0")] [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar+0")] [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar+0")] @@ -198,7 +197,7 @@ public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, Inc [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] - [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar+0")] [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar+0")] [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar+0")] [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar+0")] @@ -213,7 +212,7 @@ public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, Inc [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+0")] [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+0")] [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+0")] - [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+0")] [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar+0")] [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar+0")] [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar+0")] @@ -224,7 +223,7 @@ public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, Inc [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] - [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar+0")] @@ -239,7 +238,7 @@ public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, Inc [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+0")] - [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar+0")] @@ -249,14 +248,14 @@ public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, Inc [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] - public string GetVersionWithNoLabelOnMainAndTakeAlwaysIncrementedVersionOnFeature( + public string GetVersionWithNoLabelAndPreventIncrementWhenCurrentCommitTaggedFalseOnMain( IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) { IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithPreventIncrementWhenCurrentCommitTagged(false) .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) - .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label) - //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) - ).Build(); + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); return fixture!.GetVersion(trunkBased).FullSemVer; } @@ -374,7 +373,6 @@ public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, return fixture!.GetVersion(trunkBased).FullSemVer; } - [Ignore("Enable if WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) feature has been implemented!")] [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] @@ -390,11 +388,11 @@ public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+0")] - [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar+0")] - [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] @@ -416,7 +414,7 @@ public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+0")] [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+0")] [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+0")] - [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+0")] [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar+0")] [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar+0")] [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar+0")] @@ -442,7 +440,7 @@ public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+0")] [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+0")] [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+0")] - [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+0")] [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar+0")] [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar+0")] [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar+0")] @@ -468,7 +466,7 @@ public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+0")] - [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar+0")] @@ -478,14 +476,14 @@ public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] - public string GetVersionWithEmptyLabelOnMainAndTakeAlwaysIncrementedVersionOnFeature( + public string GetVersionWithEmptyLabelAndPreventIncrementWhenCurrentCommitTaggedFalseOnMain( IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) { IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithPreventIncrementWhenCurrentCommitTagged(false) .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) - .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label) - //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) - ).Build(); + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); return fixture!.GetVersion(trunkBased).FullSemVer; } @@ -603,7 +601,6 @@ public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, In return fixture!.GetVersion(trunkBased).FullSemVer; } - [Ignore("Enable if WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) feature has been implemented!")] [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.2+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] @@ -619,11 +616,11 @@ public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, In [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.2+0")] - [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar+0")] - [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.2+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] @@ -645,7 +642,7 @@ public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, In [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+0")] [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+0")] [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+0")] - [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+0")] [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar+0")] [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar+0")] [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar+0")] @@ -671,7 +668,7 @@ public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, In [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+0")] [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+0")] [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+0")] - [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+0")] [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar+0")] [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar+0")] [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar+0")] @@ -697,7 +694,7 @@ public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, In [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+0")] - [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar+0")] @@ -707,14 +704,14 @@ public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, In [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] - public string GetVersionWithLabelFooOnMainAndTakeAlwaysIncrementedVersionOnFeature( + public string GetVersionWithLabelFooAndPreventIncrementWhenCurrentCommitTaggedFalseOnMain( IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) { IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithPreventIncrementWhenCurrentCommitTagged(false) .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) - .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label) - //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) - ).Build(); + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); return fixture!.GetVersion(trunkBased).FullSemVer; } @@ -832,12 +829,11 @@ public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, In return fixture!.GetVersion(trunkBased).FullSemVer; } - [Ignore("Enable if WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) feature has been implemented!")] - [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar+0")] - [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] @@ -848,18 +844,18 @@ public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, In [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+0")] - [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar+0")] - [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+0")] - [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar+0")] [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar+0")] [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar+0")] [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar+0")] @@ -874,7 +870,7 @@ public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, In [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+0")] [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+0")] [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+0")] - [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+0")] [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar+0")] [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar+0")] [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar+0")] @@ -885,7 +881,7 @@ public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, In [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] - [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar+0")] [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar+0")] [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar+0")] [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar+0")] @@ -900,7 +896,7 @@ public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, In [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+0")] [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+0")] [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+0")] - [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+0")] [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar+0")] [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar+0")] [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar+0")] @@ -911,7 +907,7 @@ public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, In [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] - [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar+0")] @@ -926,7 +922,7 @@ public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, In [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+0")] - [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar+0")] @@ -936,14 +932,14 @@ public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, In [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] - public string GetVersionWithLabelBarOnMainAndTakeAlwaysIncrementedVersionOnFeature( + public string GetVersionWithLabelBarAndPreventIncrementWhenCurrentCommitTaggedFalseOnMain( IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) { IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithPreventIncrementWhenCurrentCommitTagged(false) .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) - .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label) - //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) - ).Build(); + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); return fixture!.GetVersion(trunkBased).FullSemVer; } diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitTaggedAsPreReleaseFoo.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitTaggedAsPreReleaseFoo.cs index 5eff04e7e5..9d7121241d 100644 --- a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitTaggedAsPreReleaseFoo.cs +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitTaggedAsPreReleaseFoo.cs @@ -145,7 +145,6 @@ public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, Inc return fixture!.GetVersion(trunkBased).FullSemVer; } - [Ignore("Enable if WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) feature has been implemented!")] [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.5+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] @@ -249,14 +248,14 @@ public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, Inc [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] - public string GetVersionWithNoLabelOnMainAndTakeAlwaysIncrementedVersionOnFeature( + public string GetVersionWithNoLabelAndPreventIncrementWhenCurrentCommitTaggedFalseOnMain( IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) { IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithPreventIncrementWhenCurrentCommitTagged(false) .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) - .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label) - //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) - ).Build(); + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); return fixture!.GetVersion(trunkBased).FullSemVer; } @@ -374,7 +373,6 @@ public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, return fixture!.GetVersion(trunkBased).FullSemVer; } - [Ignore("Enable if WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) feature has been implemented!")] [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] @@ -478,14 +476,14 @@ public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] - public string GetVersionWithEmptyLabelOnMainAndTakeAlwaysIncrementedVersionOnFeature( - IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + public string GetVersionWithEmptyLabelAndPreventIncrementWhenCurrentCommitTaggedFalseOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) { IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithPreventIncrementWhenCurrentCommitTagged(false) .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) - .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label) - //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) - ).Build(); + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); return fixture!.GetVersion(trunkBased).FullSemVer; } @@ -603,7 +601,6 @@ public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, In return fixture!.GetVersion(trunkBased).FullSemVer; } - [Ignore("Enable if WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) feature has been implemented!")] [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.5+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] @@ -707,14 +704,14 @@ public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, In [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] - public string GetVersionWithLabelFooOnMainAndTakeAlwaysIncrementedVersionOnFeature( + public string GetVersionWithLabelFooAndPreventIncrementWhenCurrentCommitTaggedFalseOnMain( IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) { IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithPreventIncrementWhenCurrentCommitTagged(false) .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) - .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label) - //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) - ).Build(); + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); return fixture!.GetVersion(trunkBased).FullSemVer; } @@ -832,7 +829,6 @@ public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, In return fixture!.GetVersion(trunkBased).FullSemVer; } - [Ignore("Enable if WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) feature has been implemented!")] [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.2+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar.1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+0")] @@ -936,14 +932,14 @@ public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, In [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] - public string GetVersionWithLabelBarOnMainAndTakeAlwaysIncrementedVersionOnFeature( + public string GetVersionWithLabelBarAndPreventIncrementWhenCurrentCommitTaggedFalseOnMain( IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) { IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithPreventIncrementWhenCurrentCommitTagged(false) .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) - .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label) - //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) - ).Build(); + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); return fixture!.GetVersion(trunkBased).FullSemVer; } diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitTaggedAsStable.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitTaggedAsStable.cs index 5de07cfe51..41486e0754 100644 --- a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitTaggedAsStable.cs +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitTaggedAsStable.cs @@ -145,7 +145,6 @@ public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, Inc return fixture!.GetVersion(trunkBased).FullSemVer; } - [Ignore("Enable if WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) feature has been implemented!")] [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] @@ -249,14 +248,14 @@ public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, Inc [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] - public string GetVersionWithNoLabelOnMainAndTakeAlwaysIncrementedVersionOnFeature( + public string GetVersionWithNoLabelAndPreventIncrementWhenCurrentCommitTaggedFalseOnMain( IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) { IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithPreventIncrementWhenCurrentCommitTagged(false) .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) - .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label) - //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) - ).Build(); + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); return fixture!.GetVersion(trunkBased).FullSemVer; } @@ -374,7 +373,6 @@ public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, return fixture!.GetVersion(trunkBased).FullSemVer; } - [Ignore("Enable if WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) feature has been implemented!")] [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] @@ -478,14 +476,14 @@ public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] - public string GetVersionWithEmptyLabelOnMainAndTakeAlwaysIncrementedVersionOnFeature( + public string GetVersionWithEmptyLabelAndPreventIncrementWhenCurrentCommitTaggedFalseOnMain( IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) { IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithPreventIncrementWhenCurrentCommitTagged(false) .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) - .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label) - //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) - ).Build(); + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); return fixture!.GetVersion(trunkBased).FullSemVer; } @@ -603,7 +601,6 @@ public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, In return fixture!.GetVersion(trunkBased).FullSemVer; } - [Ignore("Enable if WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) feature has been implemented!")] [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] @@ -707,14 +704,14 @@ public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, In [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] - public string GetVersionWithLabelFooOnMainAndTakeAlwaysIncrementedVersionOnFeature( + public string GetVersionWithLabelFooAndPreventIncrementWhenCurrentCommitTaggedFalseOnMain( IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) { IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithPreventIncrementWhenCurrentCommitTagged(false) .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) - .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label) - //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) - ).Build(); + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); return fixture!.GetVersion(trunkBased).FullSemVer; } @@ -832,7 +829,6 @@ public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, In return fixture!.GetVersion(trunkBased).FullSemVer; } - [Ignore("Enable if WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) feature has been implemented!")] [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar.1+0")] [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+0")] @@ -936,14 +932,14 @@ public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, In [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] - public string GetVersionWithLabelBarOnMainAndTakeAlwaysIncrementedVersionOnFeature( + public string GetVersionWithLabelBarAndPreventIncrementWhenCurrentCommitTaggedFalseOnMain( IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) { IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithPreventIncrementWhenCurrentCommitTagged(false) .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) - .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label) - //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) - ).Build(); + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); return fixture!.GetVersion(trunkBased).FullSemVer; } diff --git a/src/GitVersion.Core.Tests/VersionCalculation/NextVersionCalculatorTests.cs b/src/GitVersion.Core.Tests/VersionCalculation/NextVersionCalculatorTests.cs index e2362a17ba..5b9cbfe2e6 100644 --- a/src/GitVersion.Core.Tests/VersionCalculation/NextVersionCalculatorTests.cs +++ b/src/GitVersion.Core.Tests/VersionCalculation/NextVersionCalculatorTests.cs @@ -1,570 +1,274 @@ -//using GitVersion.Common; -//using GitVersion.Configuration; -//using GitVersion.Core.Tests.Helpers; -//using GitVersion.Core.Tests.IntegrationTests; -//using GitVersion.Logging; -//using GitVersion.VersionCalculation; -//using LibGit2Sharp; -//using Microsoft.Extensions.DependencyInjection; - -//namespace GitVersion.Core.Tests.VersionCalculation; - -//public class NextVersionCalculatorTests : TestBase -//{ -// [Test] -// public void ShouldIncrementVersionBasedOnConfig() -// { -// var contextBuilder = new GitVersionContextBuilder(); - -// contextBuilder.Build(); - -// contextBuilder.ServicesProvider.ShouldNotBeNull(); -// var nextVersionCalculator = contextBuilder.ServicesProvider.GetRequiredService(); -// nextVersionCalculator.ShouldNotBeNull(); - -// var nextVersion = nextVersionCalculator.FindVersion(); - -// nextVersion.IncrementedVersion.ToString().ShouldBe("0.0.1"); -// } - -// [Test] -// public void DoesNotIncrementWhenBaseVersionSaysNotTo() -// { -// var contextBuilder = new GitVersionContextBuilder(); - -// var overrideConfiguration = new Dictionary() -// { -// { "next-version", "1.0.0" } -// }; -// contextBuilder.WithOverrideConfiguration(overrideConfiguration).Build(); - -// contextBuilder.ServicesProvider.ShouldNotBeNull(); -// var nextVersionCalculator = contextBuilder.ServicesProvider.GetRequiredService(); - -// nextVersionCalculator.ShouldNotBeNull(); - -// var nextVersion = nextVersionCalculator.FindVersion(); - -// nextVersion.IncrementedVersion.ToString().ShouldBe("1.0.0"); -// } - -// [Test] -// public void AppliesBranchPreReleaseTag() -// { -// var contextBuilder = new GitVersionContextBuilder(); - -// contextBuilder.WithDevelopBranch().Build(); - -// contextBuilder.ServicesProvider.ShouldNotBeNull(); -// var nextVersionCalculator = contextBuilder.ServicesProvider.GetRequiredService(); -// nextVersionCalculator.ShouldNotBeNull(); - -// var nextVersion = nextVersionCalculator.FindVersion(); - -// nextVersion.IncrementedVersion.ToString("f").ShouldBe("0.1.0-alpha.1+0"); -// } - -// [Test] -// public void PreReleaseLabelCanUseBranchName() -// { -// var configuration = GitFlowConfigurationBuilder.New -// .WithNextVersion("1.0.0") -// .WithBranch("custom", builder => builder -// .WithRegularExpression("custom/") -// .WithLabel(ConfigurationConstants.BranchNamePlaceholder) -// .WithSourceBranches() -// ) -// .Build(); - -// using var fixture = new EmptyRepositoryFixture(); -// fixture.MakeACommit(); -// fixture.BranchTo("develop"); -// fixture.MakeACommit(); -// fixture.BranchTo("custom/foo"); -// fixture.MakeACommit(); - -// fixture.AssertFullSemver("1.0.0-foo.1+3", configuration); -// } - -// [Test] -// public void PreReleaseVersionMainline() -// { -// var configuration = GitFlowConfigurationBuilder.New -// .WithNextVersion("1.0.0") -// .WithBranch("unknown", builder => builder.WithDeploymentMode(DeploymentMode.Mainline)) -// .WithBranch("main", builder => builder.WithDeploymentMode(DeploymentMode.Mainline)) -// .Build(); - -// using var fixture = new EmptyRepositoryFixture(); -// fixture.MakeACommit(); -// fixture.BranchTo("foo"); -// fixture.MakeACommit(); - -// fixture.AssertFullSemver("1.0.0-foo.1", configuration); -// } - -// [Test] -// public void MergeIntoMainline() -// { -// var configuration = GitFlowConfigurationBuilder.New -// .WithNextVersion("1.0.0") -// .WithBranch("main", builder => builder.WithDeploymentMode(DeploymentMode.Mainline)) -// .Build(); - -// using var fixture = new EmptyRepositoryFixture(); -// fixture.MakeACommit(); -// fixture.BranchTo("foo"); -// fixture.MakeACommit(); -// fixture.Checkout(MainBranch); -// fixture.MergeNoFF("foo"); - -// fixture.AssertFullSemver("1.0.0", configuration); -// } - -// [Test] -// public void MergeFeatureIntoMainline() -// { -// var configuration = GitFlowConfigurationBuilder.New -// .WithBranch("main", builder => builder.WithDeploymentMode(DeploymentMode.Mainline)) -// .WithBranch("feature", builder => builder.WithDeploymentMode(DeploymentMode.Mainline)) -// .Build(); - -// using var fixture = new EmptyRepositoryFixture(); -// fixture.MakeACommit(); -// fixture.ApplyTag("1.0.0"); -// fixture.AssertFullSemver("1.0.0", configuration); - -// fixture.BranchTo("feature/foo"); -// fixture.MakeACommit(); -// fixture.AssertFullSemver("1.0.1-foo.1", configuration); -// fixture.ApplyTag("1.0.1-foo.1"); - -// fixture.Checkout(MainBranch); -// fixture.MergeNoFF("feature/foo"); -// fixture.AssertFullSemver("1.0.1", configuration); -// } - -// [Test] -// public void MergeFeatureIntoMainlineWithMinorIncrement() -// { -// var configuration = GitFlowConfigurationBuilder.New -// .WithBranch("main", builder => builder.WithDeploymentMode(DeploymentMode.Mainline)) -// .WithBranch("feature", builder => builder -// .WithDeploymentMode(DeploymentMode.Mainline) -// .WithIncrement(IncrementStrategy.Minor) -// ) -// .Build(); - -// using var fixture = new EmptyRepositoryFixture(); -// fixture.MakeACommit(); -// fixture.ApplyTag("1.0.0"); -// fixture.AssertFullSemver("1.0.0", configuration); - -// fixture.BranchTo("feature/foo"); -// fixture.MakeACommit(); -// fixture.AssertFullSemver("1.1.0-foo.1", configuration); -// fixture.ApplyTag("1.1.0-foo.1"); - -// fixture.Checkout(MainBranch); -// fixture.MergeNoFF("feature/foo"); -// fixture.AssertFullSemver("1.1.0", configuration); -// } - -// [Test] -// public void MergeFeatureIntoMainlineWithMinorIncrementAndThenMergeHotfix() -// { -// var configuration = GitFlowConfigurationBuilder.New -// .WithDeploymentMode(DeploymentMode.Mainline) -// .WithBranch("feature", builder => builder -// .WithIncrement(IncrementStrategy.Minor) -// .WithDeploymentMode(DeploymentMode.Mainline)) -// .WithBranch("hotfix", builder => builder.WithDeploymentMode(DeploymentMode.Mainline)) -// .Build(); - -// using var fixture = new EmptyRepositoryFixture(); -// fixture.MakeACommit(); -// fixture.ApplyTag("1.0.0"); -// fixture.AssertFullSemver("1.0.0", configuration); - -// fixture.BranchTo("feature/foo"); -// fixture.MakeACommit(); -// fixture.AssertFullSemver("1.1.0-foo.1", configuration); -// fixture.ApplyTag("1.1.0-foo.1"); - -// fixture.Checkout(MainBranch); -// fixture.MergeNoFF("feature/foo"); -// fixture.AssertFullSemver("1.1.0", configuration); -// fixture.ApplyTag("1.1.0"); - -// fixture.BranchTo("hotfix/bar"); -// fixture.MakeACommit(); -// fixture.AssertFullSemver("1.1.1-beta.1", configuration); -// fixture.ApplyTag("1.1.1-beta.1"); - -// fixture.Checkout(MainBranch); -// fixture.MergeNoFF("hotfix/bar"); -// fixture.AssertFullSemver("1.1.1", configuration); -// } - -// [Test] -// public void PreReleaseLabelCanUseBranchNameVariable() -// { -// var configuration = GitFlowConfigurationBuilder.New -// .WithNextVersion("1.0.0") -// .WithBranch("custom", builder => builder -// .WithRegularExpression("custom/") -// .WithLabel($"alpha.{ConfigurationConstants.BranchNamePlaceholder}") -// .WithSourceBranches() -// ) -// .Build(); - -// using var fixture = new EmptyRepositoryFixture(); -// fixture.MakeACommit(); -// fixture.BranchTo("develop"); -// fixture.MakeACommit(); -// fixture.BranchTo("custom/foo"); -// fixture.MakeACommit(); - -// fixture.AssertFullSemver("1.0.0-alpha.foo.1+3", configuration); -// } - -// [Test] -// public void PreReleaseNumberShouldBeScopeToPreReleaseLabelInContinuousDelivery() -// { -// var configuration = GitFlowConfigurationBuilder.New -// .WithBranch("main", builder => builder.WithLabel("beta")) -// .WithBranch("feature", builder => builder -// .WithDeploymentMode(DeploymentMode.ContinuousDelivery) -// ) -// .Build(); - -// using var fixture = new EmptyRepositoryFixture(); -// fixture.MakeACommit(); - -// fixture.BranchTo("feature/test"); -// fixture.MakeATaggedCommit("0.1.0-test.1"); -// fixture.MakeACommit(); - -// fixture.AssertFullSemver("0.1.0-test.2+1", configuration); - -// fixture.Checkout("main"); -// fixture.Repository.Merge("feature/test", Generate.SignatureNow()); - -// fixture.AssertFullSemver("0.1.0-beta.1+3", configuration); -// } - -// [Test] -// public void GetNextVersionOnNonMainlineBranchWithoutCommitsShouldWorkNormally() -// { -// var configuration = GitFlowConfigurationBuilder.New -// .WithNextVersion("1.0.0") -// .WithBranch("feature", builder => builder.WithDeploymentMode(DeploymentMode.Mainline)) -// .Build(); - -// using var fixture = new EmptyRepositoryFixture(); -// fixture.MakeACommit("initial commit"); -// fixture.BranchTo("feature/f1"); -// fixture.AssertFullSemver("1.0.0-f1.0", configuration); -// } - -// [Test] -// public void ChoosesHighestVersionReturnedFromStrategies() -// { -// // Arrange -// var branchMock = GitToolsTestingExtensions.CreateMockBranch("main", GitToolsTestingExtensions.CreateMockCommit()); -// var configuration = GitFlowConfigurationBuilder.New.Build(); -// var context = new GitVersionContext(branchMock, null, configuration, null, 0); -// var repositoryStoreMock = Substitute.For(); -// var effectiveConfiguration = context.Configuration.GetEffectiveConfiguration(branchMock); -// var effectiveBranchConfiguration = new EffectiveBranchConfiguration(branchMock, effectiveConfiguration); -// var effectiveBranchConfigurationFinderMock = Substitute.For(); -// effectiveBranchConfigurationFinderMock.GetConfigurations(branchMock, configuration).Returns(new[] { effectiveBranchConfiguration }); -// var incrementStrategyFinderMock = Substitute.For(); -// repositoryStoreMock.GetSourceBranches(branchMock, configuration, Arg.Any>()).Returns(Enumerable.Empty()); -// var dateTimeOffset = DateTimeOffset.Now; -// var versionStrategies = new IVersionStrategy[] { new V1Strategy(DateTimeOffset.Now), new V2Strategy(dateTimeOffset) }; -// var mainlineVersionCalculatorMock = Substitute.For(); -// mainlineVersionCalculatorMock.CreateVersionBuildMetaData(Arg.Any()).Returns(SemanticVersionBuildMetaData.Empty); -// var continuousDeploymentVersionCalculatorMock = Substitute.For(); - -// var unitUnderTest = new NextVersionCalculator( -// Substitute.For(), -// mainlineVersionCalculator: mainlineVersionCalculatorMock, -// continuousDeploymentVersionCalculator: continuousDeploymentVersionCalculatorMock, -// repositoryStoreMock, new(context), -// versionStrategies, effectiveBranchConfigurationFinderMock, -// incrementStrategyFinderMock -// ); - -// // Act -// var nextVersion = unitUnderTest.FindVersion(); - -// // Assert -// nextVersion.BaseVersion.SemanticVersion.ToString().ShouldBe("2.0.0"); -// nextVersion.BaseVersion.ShouldIncrement.ShouldBe(true); -// nextVersion.BaseVersion.BaseVersionSource.ShouldNotBeNull(); -// nextVersion.BaseVersion.BaseVersionSource.When.ShouldBe(dateTimeOffset); -// } - -// [Test] -// public void UsesWhenFromNextBestMatchIfHighestDoesntHaveWhen() -// { -// // Arrange -// var branchMock = GitToolsTestingExtensions.CreateMockBranch("main", GitToolsTestingExtensions.CreateMockCommit()); -// var configuration = GitFlowConfigurationBuilder.New.Build(); -// var context = new GitVersionContext(branchMock, null, configuration, null, 0); -// var repositoryStoreMock = Substitute.For(); -// var effectiveConfiguration = context.Configuration.GetEffectiveConfiguration(branchMock); -// var effectiveBranchConfiguration = new EffectiveBranchConfiguration(branchMock, effectiveConfiguration); -// var effectiveBranchConfigurationFinderMock = Substitute.For(); -// effectiveBranchConfigurationFinderMock.GetConfigurations(branchMock, configuration).Returns(new[] { effectiveBranchConfiguration }); -// var incrementStrategyFinderMock = Substitute.For(); -// repositoryStoreMock.GetSourceBranches(branchMock, configuration, Arg.Any>()).Returns(Enumerable.Empty()); -// var when = DateTimeOffset.Now; -// var versionStrategies = new IVersionStrategy[] { new V1Strategy(when), new V2Strategy(null) }; -// var mainlineVersionCalculatorMock = Substitute.For(); -// mainlineVersionCalculatorMock.CreateVersionBuildMetaData(Arg.Any()).Returns(SemanticVersionBuildMetaData.Empty); -// var continuousDeploymentVersionCalculatorMock = Substitute.For(); - -// var unitUnderTest = new NextVersionCalculator( -// Substitute.For(), -// mainlineVersionCalculator: mainlineVersionCalculatorMock, -// continuousDeploymentVersionCalculator: continuousDeploymentVersionCalculatorMock, -// repositoryStoreMock, new(context), -// versionStrategies, effectiveBranchConfigurationFinderMock, -// incrementStrategyFinderMock -// ); - -// // Act -// var nextVersion = unitUnderTest.FindVersion(); - -// // Assert -// nextVersion.BaseVersion.SemanticVersion.ToString().ShouldBe("2.0.0"); -// nextVersion.BaseVersion.ShouldIncrement.ShouldBe(true); -// nextVersion.BaseVersion.BaseVersionSource.ShouldNotBeNull(); -// nextVersion.BaseVersion.BaseVersionSource.When.ShouldBe(when); -// } - -// [Test] -// public void UsesWhenFromNextBestMatchIfHighestDoesntHaveWhenReversedOrder() -// { -// // Arrange -// var branchMock = GitToolsTestingExtensions.CreateMockBranch("main", GitToolsTestingExtensions.CreateMockCommit()); -// var configuration = GitFlowConfigurationBuilder.New.Build(); -// var context = new GitVersionContext(branchMock, null, configuration, null, 0); -// var repositoryStoreMock = Substitute.For(); -// var effectiveConfiguration = context.Configuration.GetEffectiveConfiguration(branchMock); -// var effectiveBranchConfiguration = new EffectiveBranchConfiguration(branchMock, effectiveConfiguration); -// var effectiveBranchConfigurationFinderMock = Substitute.For(); -// effectiveBranchConfigurationFinderMock.GetConfigurations(branchMock, configuration).Returns(new[] { effectiveBranchConfiguration }); -// var incrementStrategyFinderMock = Substitute.For(); -// repositoryStoreMock.GetSourceBranches(branchMock, configuration, Arg.Any>()).Returns(Enumerable.Empty()); -// var when = DateTimeOffset.Now; -// var versionStrategies = new IVersionStrategy[] { new V2Strategy(null), new V1Strategy(when) }; -// var mainlineVersionCalculatorMock = Substitute.For(); -// mainlineVersionCalculatorMock.CreateVersionBuildMetaData(Arg.Any()).Returns(SemanticVersionBuildMetaData.Empty); -// var continuousDeploymentVersionCalculatorMock = Substitute.For(); - -// var unitUnderTest = new NextVersionCalculator( -// Substitute.For(), -// mainlineVersionCalculator: mainlineVersionCalculatorMock, -// continuousDeploymentVersionCalculator: continuousDeploymentVersionCalculatorMock, -// repositoryStoreMock, new(context), -// versionStrategies, effectiveBranchConfigurationFinderMock, -// incrementStrategyFinderMock -// ); - -// // Act -// var nextVersion = unitUnderTest.FindVersion(); - -// // Assert -// nextVersion.BaseVersion.SemanticVersion.ToString().ShouldBe("2.0.0"); -// nextVersion.BaseVersion.ShouldIncrement.ShouldBe(true); -// nextVersion.BaseVersion.BaseVersionSource.ShouldNotBeNull(); -// nextVersion.BaseVersion.BaseVersionSource.When.ShouldBe(when); -// } - -// [Test] -// public void ShouldNotFilterVersion() -// { -// // Arrange -// var branchMock = GitToolsTestingExtensions.CreateMockBranch("main", GitToolsTestingExtensions.CreateMockCommit()); -// var configuration = GitFlowConfigurationBuilder.New.Build(); -// var context = new GitVersionContext(branchMock, null, configuration, null, 0); -// var repositoryStoreMock = Substitute.For(); -// var effectiveConfiguration = context.Configuration.GetEffectiveConfiguration(branchMock); -// var effectiveBranchConfiguration = new EffectiveBranchConfiguration(branchMock, effectiveConfiguration); -// var effectiveBranchConfigurationFinderMock = Substitute.For(); -// effectiveBranchConfigurationFinderMock.GetConfigurations(branchMock, configuration).Returns(new[] { effectiveBranchConfiguration }); -// var incrementStrategyFinderMock = Substitute.For(); -// repositoryStoreMock.GetSourceBranches(branchMock, configuration, Arg.Any>()).Returns(Enumerable.Empty()); -// var version = new BaseVersion("dummy", false, new SemanticVersion(2), GitToolsTestingExtensions.CreateMockCommit(), null); -// var versionStrategies = new IVersionStrategy[] { new TestVersionStrategy(version) }; -// var mainlineVersionCalculatorMock = Substitute.For(); -// mainlineVersionCalculatorMock.CreateVersionBuildMetaData(Arg.Any()).Returns(SemanticVersionBuildMetaData.Empty); -// var continuousDeploymentVersionCalculatorMock = Substitute.For(); - -// var unitUnderTest = new NextVersionCalculator( -// Substitute.For(), -// mainlineVersionCalculator: mainlineVersionCalculatorMock, -// continuousDeploymentVersionCalculator: continuousDeploymentVersionCalculatorMock, -// repositoryStoreMock, new(context), -// versionStrategies, effectiveBranchConfigurationFinderMock, -// incrementStrategyFinderMock -// ); - -// // Act -// var nextVersion = unitUnderTest.FindVersion(); - -// // Assert -// nextVersion.BaseVersion.Source.ShouldBe(version.Source); -// nextVersion.BaseVersion.ShouldIncrement.ShouldBe(version.ShouldIncrement); -// nextVersion.BaseVersion.SemanticVersion.ShouldBe(version.SemanticVersion); -// } - -// [Test] -// public void ShouldFilterVersion() -// { -// // Arrange -// var commitToExclude = GitToolsTestingExtensions.CreateMockCommit(); -// var branchMock = GitToolsTestingExtensions.CreateMockBranch("main", GitToolsTestingExtensions.CreateMockCommit()); -// var ignoreConfiguration = IgnoreConfigurationBuilder.New.WithShas(commitToExclude.Sha).Build(); -// var configuration = GitFlowConfigurationBuilder.New.WithIgnoreConfiguration(ignoreConfiguration).Build(); -// var context = new GitVersionContext(branchMock, null, configuration, null, 0); -// var repositoryStoreMock = Substitute.For(); -// var effectiveConfiguration = context.Configuration.GetEffectiveConfiguration(branchMock); -// var effectiveBranchConfiguration = new EffectiveBranchConfiguration(branchMock, effectiveConfiguration); -// var effectiveBranchConfigurationFinderMock = Substitute.For(); -// effectiveBranchConfigurationFinderMock.GetConfigurations(branchMock, configuration).Returns(new[] { effectiveBranchConfiguration }); -// var incrementStrategyFinderMock = Substitute.For(); -// repositoryStoreMock.GetSourceBranches(branchMock, configuration, Arg.Any>()).Returns(Enumerable.Empty()); -// var higherVersion = new BaseVersion("exclude", false, new SemanticVersion(2), commitToExclude, null); -// var lowerVersion = new BaseVersion("dummy", false, new SemanticVersion(1), GitToolsTestingExtensions.CreateMockCommit(), null); -// var versionStrategies = new IVersionStrategy[] { new TestVersionStrategy(higherVersion, lowerVersion) }; -// var mainlineVersionCalculatorMock = Substitute.For(); -// mainlineVersionCalculatorMock.CreateVersionBuildMetaData(Arg.Any()).Returns(SemanticVersionBuildMetaData.Empty); -// var continuousDeploymentVersionCalculatorMock = Substitute.For(); - -// var unitUnderTest = new NextVersionCalculator( -// Substitute.For(), -// mainlineVersionCalculator: mainlineVersionCalculatorMock, -// continuousDeploymentVersionCalculator: continuousDeploymentVersionCalculatorMock, -// repositoryStoreMock, new(context), -// versionStrategies, effectiveBranchConfigurationFinderMock, -// incrementStrategyFinderMock -// ); - -// // Act -// var nextVersion = unitUnderTest.FindVersion(); - -// // Assert -// nextVersion.BaseVersion.Source.ShouldNotBe(higherVersion.Source); -// nextVersion.BaseVersion.SemanticVersion.ShouldNotBe(higherVersion.SemanticVersion); -// nextVersion.BaseVersion.Source.ShouldBe(lowerVersion.Source); -// nextVersion.BaseVersion.SemanticVersion.ShouldBe(lowerVersion.SemanticVersion); -// } - -// [Test] -// public void ShouldIgnorePreReleaseVersionInMainlineMode() -// { -// // Arrange -// var branchMock = GitToolsTestingExtensions.CreateMockBranch("main", GitToolsTestingExtensions.CreateMockCommit()); -// var configuration = GitFlowConfigurationBuilder.New -// .WithBranch("main", builder => builder.WithDeploymentMode(DeploymentMode.Mainline)) -// .Build(); -// var context = new GitVersionContext(branchMock, null, configuration, null, 0); -// var repositoryStoreMock = Substitute.For(); -// var effectiveConfiguration = context.Configuration.GetEffectiveConfiguration(branchMock); -// var effectiveBranchConfiguration = new EffectiveBranchConfiguration(branchMock, effectiveConfiguration); -// var effectiveBranchConfigurationFinderMock = Substitute.For(); -// effectiveBranchConfigurationFinderMock.GetConfigurations(branchMock, configuration).Returns(new[] { effectiveBranchConfiguration }); -// var incrementStrategyFinderMock = Substitute.For(); -// repositoryStoreMock.GetSourceBranches(branchMock, configuration, Arg.Any>()).Returns(Enumerable.Empty()); -// var lowerVersion = new BaseVersion("dummy", false, new SemanticVersion(1), GitToolsTestingExtensions.CreateMockCommit(), null); -// var preReleaseVersion = new BaseVersion( -// "prerelease", -// false, -// new SemanticVersion(1, 0, 1) -// { -// PreReleaseTag = new SemanticVersionPreReleaseTag -// { -// Name = "alpha", -// Number = 1 -// } -// }, -// GitToolsTestingExtensions.CreateMockCommit(), -// null -// ); -// var mainlineVersionCalculatorMock = Substitute.For(); -// mainlineVersionCalculatorMock.Calculate(Arg.Any()).Returns(lowerVersion.SemanticVersion); -// var continuousDeploymentVersionCalculatorMock = Substitute.For(); - -// var versionStrategies = new IVersionStrategy[] { new TestVersionStrategy(preReleaseVersion, lowerVersion) }; -// var unitUnderTest = new NextVersionCalculator(Substitute.For(), mainlineVersionCalculatorMock, continuousDeploymentVersionCalculatorMock, -// repositoryStoreMock, new(context), versionStrategies, effectiveBranchConfigurationFinderMock, incrementStrategyFinderMock); - -// // Act -// var nextVersion = unitUnderTest.FindVersion(); - -// // Assert -// nextVersion.BaseVersion.Source.ShouldNotBe(preReleaseVersion.Source); -// nextVersion.BaseVersion.SemanticVersion.ShouldNotBe(preReleaseVersion.SemanticVersion); -// nextVersion.BaseVersion.Source.ShouldBe(lowerVersion.Source); -// nextVersion.BaseVersion.SemanticVersion.ShouldBe(lowerVersion.SemanticVersion); -// } - -// private sealed class V1Strategy : IVersionStrategy -// { -// private readonly ICommit? when; - -// public V1Strategy(DateTimeOffset? when) -// { -// if (when != null) -// { -// this.when = GitToolsTestingExtensions.CreateMockCommit(); -// this.when.When.Returns(when.Value); -// } -// else -// { -// this.when = null; -// } -// } - -// public IEnumerable GetBaseVersions(EffectiveBranchConfiguration configuration) -// { -// yield return new BaseVersion("Source 1", false, new SemanticVersion(1), this.when, null); -// } -// } - -// private sealed class V2Strategy : IVersionStrategy -// { -// private readonly ICommit? when; - -// public V2Strategy(DateTimeOffset? when) -// { -// if (when != null) -// { -// this.when = GitToolsTestingExtensions.CreateMockCommit(); -// this.when.When.Returns(when.Value); -// } -// else -// { -// this.when = null; -// } -// } - -// public IEnumerable GetBaseVersions(EffectiveBranchConfiguration configuration) -// { -// yield return new BaseVersion("Source 2", true, new SemanticVersion(2), this.when, null); -// } -// } - -// private sealed class TestVersionStrategy : IVersionStrategy -// { -// private readonly IEnumerable baseVersions; - -// public TestVersionStrategy(params BaseVersion[] baseVersions) => this.baseVersions = baseVersions; - -// public IEnumerable GetBaseVersions(EffectiveBranchConfiguration configuration) => this.baseVersions; -// } -//} +using GitVersion.Configuration; +using GitVersion.Core.Tests.Helpers; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; +using LibGit2Sharp; +using Microsoft.Extensions.DependencyInjection; + +namespace GitVersion.Core.Tests.VersionCalculation; + +public class NextVersionCalculatorTests : TestBase +{ + [Test] + public void ShouldIncrementVersionBasedOnConfig() + { + var contextBuilder = new GitVersionContextBuilder(); + + contextBuilder.Build(); + + contextBuilder.ServicesProvider.ShouldNotBeNull(); + var nextVersionCalculator = contextBuilder.ServicesProvider.GetRequiredService(); + nextVersionCalculator.ShouldNotBeNull(); + + var nextVersion = nextVersionCalculator.FindVersion(); + + nextVersion.ToString().ShouldBe("0.0.1-0"); + } + + [Test] + public void DoesNotIncrementWhenBaseVersionSaysNotTo() + { + var contextBuilder = new GitVersionContextBuilder(); + + var overrideConfiguration = new Dictionary() + { + { "next-version", "1.0.0" } + }; + contextBuilder.WithOverrideConfiguration(overrideConfiguration).Build(); + + contextBuilder.ServicesProvider.ShouldNotBeNull(); + var nextVersionCalculator = contextBuilder.ServicesProvider.GetRequiredService(); + + nextVersionCalculator.ShouldNotBeNull(); + + var nextVersion = nextVersionCalculator.FindVersion(); + + nextVersion.ToString().ShouldBe("1.0.0-0"); + } + + [Test] + public void AppliesBranchPreReleaseTag() + { + var contextBuilder = new GitVersionContextBuilder(); + + contextBuilder.WithDevelopBranch().Build(); + + contextBuilder.ServicesProvider.ShouldNotBeNull(); + var nextVersionCalculator = contextBuilder.ServicesProvider.GetRequiredService(); + nextVersionCalculator.ShouldNotBeNull(); + + var nextVersion = nextVersionCalculator.FindVersion(); + + nextVersion.ToString("f").ShouldBe("0.1.0-alpha.0"); + } + + [Test] + public void PreReleaseLabelCanUseBranchName() + { + var configuration = GitFlowConfigurationBuilder.New + .WithNextVersion("1.0.0") + .WithBranch("custom", builder => builder + .WithRegularExpression("^custom?[/-](?.+)") + .WithLabel(ConfigurationConstants.BranchNamePlaceholder) + .WithSourceBranches() + ) + .Build(); + + using var fixture = new EmptyRepositoryFixture(); + fixture.MakeACommit(); + fixture.BranchTo("develop"); + fixture.MakeACommit(); + fixture.BranchTo("custom/foo"); + fixture.MakeACommit(); + + fixture.AssertFullSemver("1.0.0-foo.3", configuration); + } + + [Test] + public void PreReleaseVersionMainline() + { + var configuration = TrunkBasedConfigurationBuilder.New.Build(); + + using var fixture = new EmptyRepositoryFixture("main"); + fixture.MakeACommit(); + fixture.MakeACommit(); + fixture.BranchTo("feature/foo"); + fixture.MakeACommit(); + + fixture.AssertFullSemver("0.1.0-foo.1", configuration); + + fixture.BranchTo("bar"); + fixture.MakeACommit(); + + fixture.AssertFullSemver("0.0.3-bar.2", configuration); + } + + [Test] + public void MergeIntoMainline() + { + var configuration = TrunkBasedConfigurationBuilder.New + .WithNextVersion("1.0.0") + .Build(); + + using var fixture = new EmptyRepositoryFixture(); + fixture.MakeACommit(); + fixture.BranchTo("foo"); + fixture.MakeACommit(); + fixture.Checkout(MainBranch); + fixture.MergeNoFF("foo"); + + fixture.AssertFullSemver("1.0.0", configuration); + } + + [Test] + public void MergeFeatureIntoMainline() + { + var configuration = TrunkBasedConfigurationBuilder.New.Build(); + + using var fixture = new EmptyRepositoryFixture("main"); + fixture.MakeACommit(); + fixture.ApplyTag("1.0.0"); + fixture.AssertFullSemver("1.0.0", configuration); + + fixture.BranchTo("feature/foo"); + fixture.MakeACommit(); + fixture.AssertFullSemver("1.1.0-foo.1", configuration); + fixture.ApplyTag("1.1.0-foo.1"); + + fixture.Checkout(MainBranch); + fixture.MergeNoFF("feature/foo"); + fixture.AssertFullSemver("1.1.0", configuration); + } + + [Test] + public void MergeHotfixIntoMainline() + { + var configuration = TrunkBasedConfigurationBuilder.New.Build(); + + using var fixture = new EmptyRepositoryFixture("main"); + fixture.MakeACommit(); + fixture.ApplyTag("1.0.0"); + fixture.AssertFullSemver("1.0.0", configuration); + + fixture.BranchTo("hotfix/foo"); + fixture.MakeACommit(); + fixture.AssertFullSemver("1.0.1-foo.1", configuration); + fixture.ApplyTag("1.0.1-foo.1"); + + fixture.Checkout(MainBranch); + fixture.MergeNoFF("hotfix/foo"); + fixture.AssertFullSemver("1.0.1", configuration); + } + + [Test] + public void MergeFeatureIntoMainlineWithMinorIncrement() + { + var configuration = TrunkBasedConfigurationBuilder.New.Build(); + + using var fixture = new EmptyRepositoryFixture(); + fixture.MakeACommit(); + fixture.ApplyTag("1.0.0"); + fixture.AssertFullSemver("1.0.0", configuration); + + fixture.BranchTo("feature/foo"); + fixture.MakeACommit(); + fixture.AssertFullSemver("1.1.0-foo.1", configuration); + fixture.ApplyTag("1.1.0-foo.1"); + + fixture.Checkout(MainBranch); + fixture.MergeNoFF("feature/foo"); + fixture.AssertFullSemver("1.1.0", configuration); + } + + [Test] + public void MergeFeatureIntoMainlineWithMinorIncrementAndThenMergeHotfix() + { + var configuration = TrunkBasedConfigurationBuilder.New.Build(); + + using var fixture = new EmptyRepositoryFixture(); + fixture.MakeACommit(); + fixture.ApplyTag("1.0.0"); + fixture.AssertFullSemver("1.0.0", configuration); + + fixture.BranchTo("feature/foo"); + fixture.MakeACommit(); + fixture.AssertFullSemver("1.1.0-foo.1", configuration); + fixture.ApplyTag("1.1.0-foo.1"); + + fixture.Checkout(MainBranch); + fixture.MergeNoFF("feature/foo"); + fixture.AssertFullSemver("1.1.0", configuration); + fixture.ApplyTag("1.1.0"); + + fixture.BranchTo("hotfix/bar"); + fixture.MakeACommit(); + fixture.AssertFullSemver("1.1.1-bar.1", configuration); + fixture.ApplyTag("1.1.1-bar.1"); + + fixture.Checkout(MainBranch); + fixture.MergeNoFF("hotfix/bar"); + fixture.AssertFullSemver("1.1.1", configuration); + } + + [Test] + public void PreReleaseLabelCanUseBranchNameVariable() + { + var configuration = GitFlowConfigurationBuilder.New + .WithNextVersion("1.0.0") + .WithBranch("custom", builder => builder + .WithRegularExpression("^custom?[/-](?.+)") + .WithLabel($"alpha.{ConfigurationConstants.BranchNamePlaceholder}") + .WithDeploymentMode(DeploymentMode.ManualDeployment) + .WithSourceBranches() + ) + .Build(); + + using var fixture = new EmptyRepositoryFixture(); + fixture.MakeACommit(); + fixture.BranchTo("develop"); + fixture.MakeACommit(); + fixture.BranchTo("custom/foo"); + fixture.MakeACommit(); + + fixture.AssertFullSemver("1.0.0-alpha.foo.1+3", configuration); + } + + [Test] + public void PreReleaseNumberShouldBeScopeToPreReleaseLabelInManualDeployment() + { + var configuration = GitFlowConfigurationBuilder.New + .WithBranch("main", builder => builder + .WithLabel("beta").WithDeploymentMode(DeploymentMode.ManualDeployment) + ).WithBranch("feature", builder => builder + .WithDeploymentMode(DeploymentMode.ManualDeployment) + ) + .Build(); + + using var fixture = new EmptyRepositoryFixture(); + fixture.MakeACommit(); + + fixture.BranchTo("feature/test"); + fixture.MakeATaggedCommit("0.1.0-test.1"); + fixture.MakeACommit(); + + fixture.AssertFullSemver("0.1.0-test.2+1", configuration); + + fixture.Checkout("main"); + fixture.Repository.Merge("feature/test", Generate.SignatureNow()); + + fixture.AssertFullSemver("0.1.0-beta.1+3", configuration); + } + + [Test] + public void GetNextVersionOnNonMainlineBranchWithoutCommitsShouldWorkNormally() + { + var configuration = TrunkBasedConfigurationBuilder.New + .WithNextVersion("1.0.0") + .Build(); + + using var fixture = new EmptyRepositoryFixture(); + fixture.MakeACommit("initial commit"); + fixture.BranchTo("feature/f1"); + fixture.AssertFullSemver("1.0.0-f1.0", configuration); + } +} diff --git a/src/GitVersion.Core/Configuration/ConfigurationConstants.cs b/src/GitVersion.Core/Configuration/ConfigurationConstants.cs index b3a8ffa6ef..b64bb3d869 100644 --- a/src/GitVersion.Core/Configuration/ConfigurationConstants.cs +++ b/src/GitVersion.Core/Configuration/ConfigurationConstants.cs @@ -42,10 +42,10 @@ internal static class ConfigurationConstants public const string MainBranchRegex = "^master$|^main$"; public const string DevelopBranchRegex = "^dev(elop)?(ment)?$"; - public const string ReleaseBranchRegex = "^releases?[/-]"; + public const string ReleaseBranchRegex = "^releases?[/-](?.+)"; public const string FeatureBranchRegex = "^features?[/-](?.+)"; public const string PullRequestBranchRegex = @"^(pull|pull\-requests|pr)[/-]"; - public const string HotfixBranchRegex = "^hotfix(es)?[/-]"; - public const string SupportBranchRegex = "^support[/-]"; + public const string HotfixBranchRegex = "^hotfix(es)?[/-](?.+)"; + public const string SupportBranchRegex = "^support[/-](?.+)"; public const string UnknownBranchRegex = "(?.+)"; } diff --git a/src/GitVersion.Core/MergeMessage.cs b/src/GitVersion.Core/MergeMessage.cs index 76cb9bcd7f..0750d5aedc 100644 --- a/src/GitVersion.Core/MergeMessage.cs +++ b/src/GitVersion.Core/MergeMessage.cs @@ -15,7 +15,8 @@ public class MergeMessage new("BitBucketPullv7", @"^Pull request #(?\d+).*\r?\n\r?\nMerge in (?.*) from (?[^\s]*) to (?[^\s]*)"), new("BitBucketCloudPull", @"^Merged in (?[^\s]*) \(pull request #(?\d+)\)"), new("GitHubPull", @"^Merge pull request #(?\d+) (from|in) (?:[^\s\/]+\/)?(?[^\s]*)(?: into (?[^\s]*))*"), - new("RemoteTracking", @"^Merge remote-tracking branch '(?[^\s]*)'(?: into (?[^\s]*))*") + new("RemoteTracking", @"^Merge remote-tracking branch '(?[^\s]*)'(?: into (?[^\s]*))*"), + new("AzureDevOpsPull", @"^Merge pull request (?\d+) from (?[^\s]*) into (?[^\s]*)") }; public MergeMessage(string mergeMessage, IGitVersionConfiguration configuration) diff --git a/src/GitVersion.Core/VersionCalculation/TrunkBased/Trunk/CommitOnTrunk.cs b/src/GitVersion.Core/VersionCalculation/TrunkBased/Trunk/CommitOnTrunk.cs index bb5411fe2d..558e3c914e 100644 --- a/src/GitVersion.Core/VersionCalculation/TrunkBased/Trunk/CommitOnTrunk.cs +++ b/src/GitVersion.Core/VersionCalculation/TrunkBased/Trunk/CommitOnTrunk.cs @@ -30,7 +30,5 @@ public IEnumerable GetIncrements(TrunkBasedIteration iteration, T ); context.BaseVersionSource = commit.Value; - context.Increment = VersionField.None; - context.Label = null; } } diff --git a/src/GitVersion.Core/VersionCalculation/TrunkBased/Trunk/CommitOnTrunkBranchedBase.cs b/src/GitVersion.Core/VersionCalculation/TrunkBased/Trunk/CommitOnTrunkBranchedBase.cs index 94296d7663..db20d39e2b 100644 --- a/src/GitVersion.Core/VersionCalculation/TrunkBased/Trunk/CommitOnTrunkBranchedBase.cs +++ b/src/GitVersion.Core/VersionCalculation/TrunkBased/Trunk/CommitOnTrunkBranchedBase.cs @@ -1,5 +1,4 @@ using GitVersion.Configuration; -using GitVersion.Extensions; namespace GitVersion.VersionCalculation.TrunkBased.Trunk; @@ -8,13 +7,14 @@ internal abstract class CommitOnTrunkBranchedBase : ITrunkBasedIncrementer public virtual bool MatchPrecondition(TrunkBasedIteration iteration, TrunkBasedCommit commit, TrunkBasedContext context) => commit.Configuration.IsMainBranch && commit.BranchName != iteration.BranchName && commit.Successor is null; - public virtual IEnumerable GetIncrements(TrunkBasedIteration iteration, TrunkBasedCommit commit, TrunkBasedContext context) + public virtual IEnumerable GetIncrements( + TrunkBasedIteration iteration, TrunkBasedCommit commit, TrunkBasedContext context) { context.BaseVersionSource = commit.Value; var incrementForcedByBranch = iteration.Configuration.Increment == IncrementStrategy.Inherit ? commit.GetIncrementForcedByBranch() : iteration.Configuration.Increment.ToVersionField(); - context.Increment = context.Increment.Consolidate(incrementForcedByBranch); + context.Increment = incrementForcedByBranch; context.Label = iteration.Configuration.GetBranchSpecificLabel(iteration.BranchName, null) ?? context.Label; context.ForceIncrement = true; diff --git a/src/GitVersion.Core/VersionCalculation/TrunkBased/Trunk/CommitOnTrunkWithPreReleaseTagBase.cs b/src/GitVersion.Core/VersionCalculation/TrunkBased/Trunk/CommitOnTrunkWithPreReleaseTagBase.cs index 8dcd971faf..5b92871f58 100644 --- a/src/GitVersion.Core/VersionCalculation/TrunkBased/Trunk/CommitOnTrunkWithPreReleaseTagBase.cs +++ b/src/GitVersion.Core/VersionCalculation/TrunkBased/Trunk/CommitOnTrunkWithPreReleaseTagBase.cs @@ -17,7 +17,5 @@ public virtual IEnumerable GetIncrements(TrunkBasedIteration iter baseVersionSource: context.BaseVersionSource, semanticVersion: context.SemanticVersion.NotNull() ); - - context.Increment = VersionField.None; } } diff --git a/src/GitVersion.Core/VersionCalculation/TrunkBased/Trunk/LastCommitOnTrunkWithPreReleaseTag.cs b/src/GitVersion.Core/VersionCalculation/TrunkBased/Trunk/LastCommitOnTrunkWithPreReleaseTag.cs index f64090f06d..0109a65ab4 100644 --- a/src/GitVersion.Core/VersionCalculation/TrunkBased/Trunk/LastCommitOnTrunkWithPreReleaseTag.cs +++ b/src/GitVersion.Core/VersionCalculation/TrunkBased/Trunk/LastCommitOnTrunkWithPreReleaseTag.cs @@ -30,9 +30,6 @@ public override IEnumerable GetIncrements(TrunkBasedIteration ite label: context.Label, forceIncrement: context.ForceIncrement ); - - context.Increment = VersionField.None; - context.Label = null; } } } diff --git a/src/GitVersion.Core/VersionCalculation/TrunkBased/Trunk/MergeCommitOnTrunkBase.cs b/src/GitVersion.Core/VersionCalculation/TrunkBased/Trunk/MergeCommitOnTrunkBase.cs index db70c621ab..eab7856088 100644 --- a/src/GitVersion.Core/VersionCalculation/TrunkBased/Trunk/MergeCommitOnTrunkBase.cs +++ b/src/GitVersion.Core/VersionCalculation/TrunkBased/Trunk/MergeCommitOnTrunkBase.cs @@ -63,7 +63,5 @@ public virtual IEnumerable GetIncrements(TrunkBasedIteration iter ); context.BaseVersionSource = commit.Value; - context.Increment = VersionField.None; - context.Label = null; } } diff --git a/src/GitVersion.MsBuild/GitVersionTaskExecutor.cs b/src/GitVersion.MsBuild/GitVersionTaskExecutor.cs index 9627f2615a..9252d5a6b5 100644 --- a/src/GitVersion.MsBuild/GitVersionTaskExecutor.cs +++ b/src/GitVersion.MsBuild/GitVersionTaskExecutor.cs @@ -100,9 +100,5 @@ public void WriteVersionInfoToBuildLog(WriteVersionInfoToBuildLog task) gitVersionOutputTool.OutputVariables(versionVariables, configuration.UpdateBuildNumber); } - private GitVersionVariables GitVersionVariables(GitVersionTaskBase task) - { - var versionVariables = serializer.FromFile(task.VersionFile); - return versionVariables; - } + private GitVersionVariables GitVersionVariables(GitVersionTaskBase task) => serializer.FromFile(task.VersionFile); }