From cc5cc7cc5890f71330112aaa72d0c561cb273c88 Mon Sep 17 00:00:00 2001 From: HHobeck Date: Thu, 25 Jan 2024 11:15:37 +0100 Subject: [PATCH] Add new property with name strategy (type VersionStrategies) to the configuration root level. --- BREAKING_CHANGES.md | 11 +- docs/input/docs/reference/configuration.md | 12 + .../ConfigurationBuilderBase.cs | 9 + .../ConfigurationFileLocator.cs | 20 +- .../GitFlowConfigurationBuilder.cs | 1 + .../GitHubFlowConfigurationBuilder.cs | 1 + .../GitVersion.Configuration.csproj | 4 + .../GitVersionConfiguration.cs | 5 + .../Init/SetConfig/GlobalModeSetting.cs | 6 +- .../SupportedWorkflows/GitFlow/v1.yml | 1 + .../SupportedWorkflows/GitHubFlow/v1.yml | 1 + .../SupportedWorkflows/TrunkBased/v1.yml | 83 + ...ngTheBehaviorOfDifferentVersioningModes.cs | 12 +- .../TrunkBasedDevelopmentScenarios.cs | 4 +- .../VersionBumpingScenarios.cs | 2 +- ...elopBranchWithOneCommitMergedToMainWhen.cs | 98 ++ ...gedToMainWhenMergedCommitTaggedAsStable.cs | 100 ++ ...MergeCommitFromMainMergedBackToMainWhen.cs | 236 +++ ...atureBranchWithAMergeCommitFromMainWhen.cs | 175 ++ ...BranchWithOneCommitBranchedFromMainWhen.cs | 488 ++++++ ...dFromMainWhenCommitAHasBumpMessageMajor.cs | 1409 ++++++++++++++++ ...dFromMainWhenCommitAHasBumpMessageMinor.cs | 1409 ++++++++++++++++ ...dFromMainWhenCommitAHasBumpMessagePatch.cs | 1408 ++++++++++++++++ ...edFromMainWhenCommitATaggedAsPreRelease.cs | 489 ++++++ ...romMainWhenCommitATaggedAsPreReleaseBar.cs | 489 ++++++ ...romMainWhenCommitATaggedAsPreReleaseFoo.cs | 489 ++++++ ...anchedFromMainWhenCommitATaggedAsStable.cs | 493 ++++++ ...dFromMainWhenCommitBHasBumpMessageMajor.cs | 1416 +++++++++++++++++ ...dFromMainWhenCommitBHasBumpMessageMinor.cs | 1416 +++++++++++++++++ ...dFromMainWhenCommitBHasBumpMessagePatch.cs | 1416 +++++++++++++++++ ...edFromMainWhenCommitBTaggedAsPreRelease.cs | 489 ++++++ ...romMainWhenCommitBTaggedAsPreReleaseBar.cs | 489 ++++++ ...romMainWhenCommitBTaggedAsPreReleaseFoo.cs | 489 ++++++ ...anchedFromMainWhenCommitBTaggedAsStable.cs | 877 ++++++++++ ...tureBranchWithOneCommitMergedToMainWhen.cs | 956 +++++++++++ ...rgedToMainWhenCommitBTaggedAsPreRelease.cs | 950 +++++++++++ ...dToMainWhenCommitBTaggedAsPreReleaseBar.cs | 949 +++++++++++ ...dToMainWhenCommitBTaggedAsPreReleaseFoo.cs | 949 +++++++++++ ...itMergedToMainWhenCommitBTaggedAsStable.cs | 949 +++++++++++ ...oMainWithOneCommitBranchedToFeatureWhen.cs | 961 +++++++++++ ...ow+GivenAFeatureBranchWithOneCommitWhen.cs | 60 + ...hOneCommitWhenCommitHasBumpMessageMajor.cs | 118 ++ ...hOneCommitWhenCommitHasBumpMessageMinor.cs | 118 ++ ...hOneCommitWhenCommitHasBumpMessagePatch.cs | 118 ++ ...thOneCommitWhenCommitTaggedAsPreRelease.cs | 91 ++ ...neCommitWhenCommitTaggedAsPreReleaseBar.cs | 91 ++ ...neCommitWhenCommitTaggedAsPreReleaseFoo.cs | 91 ++ ...chWithOneCommitWhenCommitTaggedAsStable.cs | 91 ++ ...nchWithThreeCommitsBranchedFromMainWhen.cs | 319 ++++ ...eBranchWithThreeCommitsMergedToMainWhen.cs | 960 +++++++++++ ...GivenAFeatureBranchWithThreeCommitsWhen.cs | 64 + ...ranchWithTwoCommitsBranchedFromMainWhen.cs | 317 ++++ ...ureBranchWithTwoCommitsMergedToMainWhen.cs | 958 +++++++++++ ...ommitsWhenFirstCommitTaggedAsPreRelease.cs | 63 + ...itsWhenFirstCommitTaggedAsPreReleaseBar.cs | 63 + ...itsWhenFirstCommitTaggedAsPreReleaseFoo.cs | 63 + ...ranchWithOneCommitBranchedToFeatureWhen.cs | 487 ++++++ ...dToFeatureWhenCommitHasBumpMessageMajor.cs | 1407 ++++++++++++++++ ...dToFeatureWhenCommitHasBumpMessageMinor.cs | 1407 ++++++++++++++++ ...dToFeatureWhenCommitHasBumpMessagePatch.cs | 1406 ++++++++++++++++ ...edToFeatureWhenCommitTaggedAsPreRelease.cs | 951 +++++++++++ ...oFeatureWhenCommitTaggedAsPreReleaseBar.cs | 951 +++++++++++ ...oFeatureWhenCommitTaggedAsPreReleaseFoo.cs | 951 +++++++++++ ...anchedToFeatureWhenCommitTaggedAsStable.cs | 951 +++++++++++ ...bFlow+GivenAMainBranchWithOneCommitWhen.cs | 60 + ...hOneCommitWhenCommitHasBumpMessageMajor.cs | 118 ++ ...hOneCommitWhenCommitHasBumpMessageMinor.cs | 118 ++ ...hOneCommitWhenCommitHasBumpMessagePatch.cs | 118 ++ ...thOneCommitWhenCommitTaggedAsPreRelease.cs | 61 + ...neCommitWhenCommitTaggedAsPreReleaseBar.cs | 61 + ...neCommitWhenCommitTaggedAsPreReleaseFoo.cs | 61 + ...chWithOneCommitWhenCommitTaggedAsStable.cs | 61 + ...ow+GivenAMainBranchWithThreeCommitsWhen.cs | 64 + ...anchWithTwoCommitsBranchedToFeatureWhen.cs | 488 ++++++ ...atureWhenFirstCommitHasBumpMessageMajor.cs | 1409 ++++++++++++++++ ...atureWhenFirstCommitHasBumpMessageMinor.cs | 1409 ++++++++++++++++ ...atureWhenFirstCommitHasBumpMessagePatch.cs | 1409 ++++++++++++++++ ...eatureWhenFirstCommitTaggedAsPreRelease.cs | 489 ++++++ ...ureWhenFirstCommitTaggedAsPreReleaseBar.cs | 489 ++++++ ...ureWhenFirstCommitTaggedAsPreReleaseFoo.cs | 489 ++++++ ...dToFeatureWhenFirstCommitTaggedAsStable.cs | 489 ++++++ ...Flow+GivenAMainBranchWithTwoCommitsWhen.cs | 62 + ...mmitsWhenFirstCommitHasBumpMessageMajor.cs | 120 ++ ...mmitsWhenFirstCommitHasBumpMessageMinor.cs | 120 ++ ...mmitsWhenFirstCommitHasBumpMessagePatch.cs | 120 ++ ...ommitsWhenFirstCommitTaggedAsPreRelease.cs | 63 + ...itsWhenFirstCommitTaggedAsPreReleaseBar.cs | 63 + ...itsWhenFirstCommitTaggedAsPreReleaseFoo.cs | 63 + ...TwoCommitsWhenFirstCommitTaggedAsStable.cs | 63 + ...mitsWhenSecondCommitHasBumpMessageMajor.cs | 120 ++ ...mitsWhenSecondCommitHasBumpMessageMinor.cs | 120 ++ ...mitsWhenSecondCommitHasBumpMessagePatch.cs | 120 ++ ...mmitsWhenSecondCommitTaggedAsPreRelease.cs | 63 + ...tsWhenSecondCommitTaggedAsPreReleaseBar.cs | 63 + ...tsWhenSecondCommitTaggedAsPreReleaseFoo.cs | 63 + ...woCommitsWhenSecondCommitTaggedAsStable.cs | 63 + ...EffectiveBranchConfigurationFinderTests.cs | 1 - .../Configuration/ConfigurationConstants.cs | 2 + .../Configuration/EffectiveConfiguration.cs | 5 +- .../Configuration/IGitVersionConfiguration.cs | 3 + src/GitVersion.Core/PublicAPI.Unshipped.txt | 13 +- .../VersionCalculation/DeploymentMode.cs | 3 +- .../ConfigNextVersionVersionStrategy.cs | 3 + .../MergeMessageVersionStrategy.cs | 2 +- .../TaggedCommitVersionStrategy.cs | 2 +- .../TrackReleaseBranchesVersionStrategy.cs | 3 +- .../TrunkBasedVersionStrategy.cs | 3 +- .../VersionInBranchNameVersionStrategy.cs | 3 +- .../VersionCalculation/VersionStrategies.cs | 14 + 109 files changed, 40550 insertions(+), 43 deletions(-) create mode 100644 src/GitVersion.Configuration/SupportedWorkflows/TrunkBased/v1.yml create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitFlow+GivenADevelopBranchWithOneCommitMergedToMainWhen.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitFlow+GivenADevelopBranchWithOneCommitMergedToMainWhenMergedCommitTaggedAsStable.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithAMergeCommitFromMainMergedBackToMainWhen.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithAMergeCommitFromMainWhen.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhen.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitAHasBumpMessageMajor.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitAHasBumpMessageMinor.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitAHasBumpMessagePatch.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitATaggedAsPreRelease.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitATaggedAsPreReleaseBar.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitATaggedAsPreReleaseFoo.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitATaggedAsStable.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitBHasBumpMessageMajor.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitBHasBumpMessageMinor.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitBHasBumpMessagePatch.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitBTaggedAsPreRelease.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitBTaggedAsPreReleaseBar.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitBTaggedAsPreReleaseFoo.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitBTaggedAsStable.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitMergedToMainWhen.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitMergedToMainWhenCommitBTaggedAsPreRelease.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitMergedToMainWhenCommitBTaggedAsPreReleaseBar.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitMergedToMainWhenCommitBTaggedAsPreReleaseFoo.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitMergedToMainWhenCommitBTaggedAsStable.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitMergedToMainWithOneCommitBranchedToFeatureWhen.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhen.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitHasBumpMessageMajor.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitHasBumpMessageMinor.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitHasBumpMessagePatch.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitTaggedAsPreRelease.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitTaggedAsPreReleaseBar.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitTaggedAsPreReleaseFoo.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitTaggedAsStable.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithThreeCommitsBranchedFromMainWhen.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithThreeCommitsMergedToMainWhen.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithThreeCommitsWhen.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithTwoCommitsBranchedFromMainWhen.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithTwoCommitsMergedToMainWhen.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithTwoCommitsWhenFirstCommitTaggedAsPreRelease.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithTwoCommitsWhenFirstCommitTaggedAsPreReleaseBar.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithTwoCommitsWhenFirstCommitTaggedAsPreReleaseFoo.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhen.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitHasBumpMessageMajor.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitHasBumpMessageMinor.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitHasBumpMessagePatch.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitTaggedAsPreRelease.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitTaggedAsPreReleaseBar.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitTaggedAsPreReleaseFoo.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitTaggedAsStable.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitWhen.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitWhenCommitHasBumpMessageMajor.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitWhenCommitHasBumpMessageMinor.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitWhenCommitHasBumpMessagePatch.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitWhenCommitTaggedAsPreRelease.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitWhenCommitTaggedAsPreReleaseBar.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitWhenCommitTaggedAsPreReleaseFoo.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitWhenCommitTaggedAsStable.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithThreeCommitsWhen.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsBranchedToFeatureWhen.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsBranchedToFeatureWhenFirstCommitHasBumpMessageMajor.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsBranchedToFeatureWhenFirstCommitHasBumpMessageMinor.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsBranchedToFeatureWhenFirstCommitHasBumpMessagePatch.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsBranchedToFeatureWhenFirstCommitTaggedAsPreRelease.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsBranchedToFeatureWhenFirstCommitTaggedAsPreReleaseBar.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsBranchedToFeatureWhenFirstCommitTaggedAsPreReleaseFoo.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsBranchedToFeatureWhenFirstCommitTaggedAsStable.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhen.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenFirstCommitHasBumpMessageMajor.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenFirstCommitHasBumpMessageMinor.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenFirstCommitHasBumpMessagePatch.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenFirstCommitTaggedAsPreRelease.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenFirstCommitTaggedAsPreReleaseBar.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenFirstCommitTaggedAsPreReleaseFoo.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenFirstCommitTaggedAsStable.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenSecondCommitHasBumpMessageMajor.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenSecondCommitHasBumpMessageMinor.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenSecondCommitHasBumpMessagePatch.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenSecondCommitTaggedAsPreRelease.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenSecondCommitTaggedAsPreReleaseBar.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenSecondCommitTaggedAsPreReleaseFoo.cs create mode 100644 src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenSecondCommitTaggedAsStable.cs create mode 100644 src/GitVersion.Core/VersionCalculation/VersionStrategies.cs diff --git a/BREAKING_CHANGES.md b/BREAKING_CHANGES.md index cc1b75e6fe..29e14efe53 100644 --- a/BREAKING_CHANGES.md +++ b/BREAKING_CHANGES.md @@ -32,12 +32,21 @@ * The `BranchPrefixToTrim` configuration property has been removed. `RegularExpression` is now used to capture named groups instead. * Default `RegularExpression` for feature branches is changed from `^features?[/-]` to `^features?[/-](?.+)` to support using `{BranchName}` out-of-the-box * Default `RegularExpression` for unknown branches is changed from `.*` to `(?.*)` to support using `{BranchName}` out-of-the-box +* The `Mainline` mode and the related implementation has been removed completely. The new `TrunkBased` version strategy should be used instead. * The branch related property `is-mainline` in the configuration system has been renamed to `is-main-branch` * The versioning mode has been renamed to deployment mode and consists of following values: * ManualDeployment (previously ContinuousDelivery) * ContinuousDelivery (previously ContinuousDeployment) * ContinuousDeployment (new) - +* On the configuration root level a new property with name `version-strategy` has been introduced with following values: + * ConfigNext + * MergeMessage + * TaggedCommit + * TrackReleaseBranches + * VersionInBranchName + * NonTrunkBased = ConfigNext | MergeMessage | TaggedCommit | TrackReleaseBranches | VersionInBranchName, + * TrunkBased + ## v5.0.0 * Version numbers in branches other than `release` branches are no longer diff --git a/docs/input/docs/reference/configuration.md b/docs/input/docs/reference/configuration.md index 6a179fa957..5d5add3d49 100644 --- a/docs/input/docs/reference/configuration.md +++ b/docs/input/docs/reference/configuration.md @@ -53,6 +53,7 @@ commit-date-format: yyyy-MM-dd merge-message-formats: {} update-build-number: true semantic-version-format: Strict +version-strategy: NonTrunkBased branches: develop: mode: ContinuousDeployment @@ -684,3 +685,14 @@ Example of invalid `Strict`, but valid `Loose` [modes]: /docs/reference/modes [variables]: /docs/reference/variables [version-sources]: /docs/reference/version-sources + +### version-strategy + +Specifies which version strategy implementation (one ore more) will be used to determine the next version. Following values are supported and can be combined: +* ConfigNext +* MergeMessage +* TaggedCommit +* TrackReleaseBranches +* VersionInBranchName +* NonTrunkBased = ConfigNext,MergeMessage,TaggedCommit,TrackReleaseBranches,VersionInBranchName +* TrunkBased \ No newline at end of file diff --git a/src/GitVersion.Configuration/ConfigurationBuilderBase.cs b/src/GitVersion.Configuration/ConfigurationBuilderBase.cs index 8cc7e81ca4..72059054a9 100644 --- a/src/GitVersion.Configuration/ConfigurationBuilderBase.cs +++ b/src/GitVersion.Configuration/ConfigurationBuilderBase.cs @@ -24,6 +24,7 @@ internal abstract class ConfigurationBuilderBase : IConfi private string? commitDateFormat; private bool updateBuildNumber; private SemanticVersionFormat semanticVersionFormat; + private VersionStrategies versionStrategy; private Dictionary mergeMessageFormats = new(); private readonly List> overrides = new(); private readonly Dictionary branchConfigurationBuilders = new(); @@ -199,6 +200,12 @@ public virtual TConfigurationBuilder WithSemanticVersionFormat(SemanticVersionFo return (TConfigurationBuilder)this; } + public virtual TConfigurationBuilder WithVersionStrategy(VersionStrategies value) + { + this.versionStrategy = value; + return (TConfigurationBuilder)this; + } + public virtual TConfigurationBuilder WithMergeMessageFormats(IReadOnlyDictionary value) { this.mergeMessageFormats = new(value); @@ -321,6 +328,7 @@ public virtual TConfigurationBuilder WithConfiguration(IGitVersionConfiguration WithCommitDateFormat(value.CommitDateFormat); WithUpdateBuildNumber(value.UpdateBuildNumber); WithSemanticVersionFormat(value.SemanticVersionFormat); + WithVersionStrategy(value.VersionStrategy); WithMergeMessageFormats(value.MergeMessageFormats); foreach (var (name, branchConfiguration) in value.Branches) { @@ -377,6 +385,7 @@ public virtual IGitVersionConfiguration Build() CommitDateFormat = this.commitDateFormat, UpdateBuildNumber = this.updateBuildNumber, SemanticVersionFormat = this.semanticVersionFormat, + VersionStrategy = this.versionStrategy, Branches = branches, MergeMessageFormats = this.mergeMessageFormats, DeploymentMode = this.versioningMode, diff --git a/src/GitVersion.Configuration/ConfigurationFileLocator.cs b/src/GitVersion.Configuration/ConfigurationFileLocator.cs index 1a0a3425d9..4421d46383 100644 --- a/src/GitVersion.Configuration/ConfigurationFileLocator.cs +++ b/src/GitVersion.Configuration/ConfigurationFileLocator.cs @@ -1,6 +1,5 @@ using GitVersion.Extensions; using GitVersion.Helpers; -using GitVersion.VersionCalculation; using Microsoft.Extensions.Options; namespace GitVersion.Configuration; @@ -29,11 +28,7 @@ public IGitVersionConfiguration ReadConfiguration(string? configFilePath) if (configFilePath == null || !fileSystem.Exists(configFilePath)) return new GitVersionConfiguration(); var readAllText = fileSystem.ReadAllText(configFilePath); - var readConfig = ConfigurationSerializer.Read(new StringReader(readAllText)); - - VerifyReadConfig(readConfig); - - return readConfig; + return ConfigurationSerializer.Read(new StringReader(readAllText)); } public IReadOnlyDictionary? ReadOverrideConfiguration(string? configFilePath) @@ -64,19 +59,6 @@ bool HasConfigurationFileAt(string fileName, out string? configFile) || HasConfigurationFileAt(DefaultAlternativeFileName, out path); } - private static void VerifyReadConfig(IGitVersionConfiguration configuration) - { - // Verify no branches are set to TrunkBased mode - if (configuration.Branches.Any(b => b.Value.DeploymentMode == DeploymentMode.TrunkBased)) - { - throw new ConfigurationException(@"TrunkBased mode only works at the repository level, a single branch cannot be put into TrunkBased mode - -This is because TrunkBased mode treats your entire git repository as an event source with each merge into the 'TrunkBased' incrementing the version. - -If the docs do not help you decide on the mode open an issue to discuss what you are trying to do."); - } - } - private void WarnAboutAmbiguousConfigFileSelection(string? workingDirectory, string? projectRootDirectory) { TryGetConfigurationFile(workingDirectory, null, out var workingConfigFile); diff --git a/src/GitVersion.Configuration/GitFlowConfigurationBuilder.cs b/src/GitVersion.Configuration/GitFlowConfigurationBuilder.cs index 763e43e91d..2c6d54e8d3 100644 --- a/src/GitVersion.Configuration/GitFlowConfigurationBuilder.cs +++ b/src/GitVersion.Configuration/GitFlowConfigurationBuilder.cs @@ -18,6 +18,7 @@ private GitFlowConfigurationBuilder() NoBumpMessage = IncrementStrategyFinder.DefaultNoBumpPattern, PatchVersionBumpMessage = IncrementStrategyFinder.DefaultPatchPattern, SemanticVersionFormat = ConfigurationConstants.DefaultSemanticVersionFormat, + VersionStrategy = ConfigurationConstants.DefaultVersionStrategy, TagPrefix = ConfigurationConstants.DefaultTagPrefix, VersionInBranchPattern = ConfigurationConstants.DefaultVersionInBranchPattern, TagPreReleaseWeight = ConfigurationConstants.DefaultTagPreReleaseWeight, diff --git a/src/GitVersion.Configuration/GitHubFlowConfigurationBuilder.cs b/src/GitVersion.Configuration/GitHubFlowConfigurationBuilder.cs index 9b792ae976..05dcd05a7f 100644 --- a/src/GitVersion.Configuration/GitHubFlowConfigurationBuilder.cs +++ b/src/GitVersion.Configuration/GitHubFlowConfigurationBuilder.cs @@ -18,6 +18,7 @@ private GitHubFlowConfigurationBuilder() NoBumpMessage = IncrementStrategyFinder.DefaultNoBumpPattern, PatchVersionBumpMessage = IncrementStrategyFinder.DefaultPatchPattern, SemanticVersionFormat = ConfigurationConstants.DefaultSemanticVersionFormat, + VersionStrategy = ConfigurationConstants.DefaultVersionStrategy, TagPrefix = ConfigurationConstants.DefaultTagPrefix, VersionInBranchPattern = ConfigurationConstants.DefaultVersionInBranchPattern, TagPreReleaseWeight = ConfigurationConstants.DefaultTagPreReleaseWeight, diff --git a/src/GitVersion.Configuration/GitVersion.Configuration.csproj b/src/GitVersion.Configuration/GitVersion.Configuration.csproj index 8d6358dd77..73acc1ab24 100644 --- a/src/GitVersion.Configuration/GitVersion.Configuration.csproj +++ b/src/GitVersion.Configuration/GitVersion.Configuration.csproj @@ -1,4 +1,7 @@ + + + @@ -10,6 +13,7 @@ + diff --git a/src/GitVersion.Configuration/GitVersionConfiguration.cs b/src/GitVersion.Configuration/GitVersionConfiguration.cs index a87959a8d9..f0e7cf1abc 100644 --- a/src/GitVersion.Configuration/GitVersionConfiguration.cs +++ b/src/GitVersion.Configuration/GitVersionConfiguration.cs @@ -124,6 +124,11 @@ public string? NextVersion [JsonPropertyDefault(DefaultSemanticVersionFormat)] public SemanticVersionFormat SemanticVersionFormat { get; internal set; } + [JsonPropertyName("version-strategy")] + [JsonPropertyDescription($"Specifies which version strategy (one or more) will be used to determine the next version. Following values are available: 'ConfigNext', 'MergeMessage', 'TaggedCommit', 'TrackReleaseBranches', 'VersionInBranchName' and 'TrunkBased'.")] + [JsonPropertyDefault(DefaultVersionStrategy)] + public VersionStrategies VersionStrategy { get; internal set; } + [JsonIgnore] IReadOnlyDictionary IGitVersionConfiguration.Branches => Branches.ToDictionary(element => element.Key, element => (IBranchConfiguration)element.Value); diff --git a/src/GitVersion.Configuration/Init/SetConfig/GlobalModeSetting.cs b/src/GitVersion.Configuration/Init/SetConfig/GlobalModeSetting.cs index 3e965d0561..79e954b0f5 100644 --- a/src/GitVersion.Configuration/Init/SetConfig/GlobalModeSetting.cs +++ b/src/GitVersion.Configuration/Init/SetConfig/GlobalModeSetting.cs @@ -23,15 +23,15 @@ protected override StepResult HandleResult( switch (result) { case "1": - configurationBuilder.WithDeploymentMode(DeploymentMode.ContinuousDelivery); + configurationBuilder.WithDeploymentMode(DeploymentMode.ManualDeployment); steps.Enqueue(this.returnToStep); return StepResult.Ok(); case "2": - configurationBuilder.WithDeploymentMode(DeploymentMode.ContinuousDeployment); + configurationBuilder.WithDeploymentMode(DeploymentMode.ContinuousDelivery); steps.Enqueue(this.returnToStep); return StepResult.Ok(); case "3": - configurationBuilder.WithDeploymentMode(DeploymentMode.TrunkBased); + configurationBuilder.WithDeploymentMode(DeploymentMode.ContinuousDeployment); steps.Enqueue(this.returnToStep); return StepResult.Ok(); case "0": diff --git a/src/GitVersion.Configuration/SupportedWorkflows/GitFlow/v1.yml b/src/GitVersion.Configuration/SupportedWorkflows/GitFlow/v1.yml index 83da461357..2bcee1eda8 100644 --- a/src/GitVersion.Configuration/SupportedWorkflows/GitFlow/v1.yml +++ b/src/GitVersion.Configuration/SupportedWorkflows/GitFlow/v1.yml @@ -10,6 +10,7 @@ commit-date-format: yyyy-MM-dd merge-message-formats: {} update-build-number: true semantic-version-format: Strict +versioning-strategy: 'ConfigNext,MergeMessage,TaggedCommit,TrackReleaseBranches,VersionInBranchName' branches: develop: mode: ContinuousDeployment diff --git a/src/GitVersion.Configuration/SupportedWorkflows/GitHubFlow/v1.yml b/src/GitVersion.Configuration/SupportedWorkflows/GitHubFlow/v1.yml index 79d1b21710..61820aa3ee 100644 --- a/src/GitVersion.Configuration/SupportedWorkflows/GitHubFlow/v1.yml +++ b/src/GitVersion.Configuration/SupportedWorkflows/GitHubFlow/v1.yml @@ -10,6 +10,7 @@ commit-date-format: yyyy-MM-dd merge-message-formats: {} update-build-number: true semantic-version-format: Strict +versioning-strategy: 'ConfigNext,MergeMessage,TaggedCommit,TrackReleaseBranches,VersionInBranchName' branches: main: label: '' diff --git a/src/GitVersion.Configuration/SupportedWorkflows/TrunkBased/v1.yml b/src/GitVersion.Configuration/SupportedWorkflows/TrunkBased/v1.yml new file mode 100644 index 0000000000..581d18d371 --- /dev/null +++ b/src/GitVersion.Configuration/SupportedWorkflows/TrunkBased/v1.yml @@ -0,0 +1,83 @@ +assembly-versioning-scheme: MajorMinorPatch +assembly-file-versioning-scheme: MajorMinorPatch +tag-prefix: '[vV]?' +major-version-bump-message: '\+semver:\s?(breaking|major)' +minor-version-bump-message: '\+semver:\s?(feature|minor)' +patch-version-bump-message: '\+semver:\s?(fix|patch)' +no-bump-message: '\+semver:\s?(none|skip)' +tag-pre-release-weight: 60000 +commit-date-format: yyyy-MM-dd +merge-message-formats: {} +update-build-number: true +semantic-version-format: Strict +versioning-strategy: TrunkBased +branches: + main: + label: '' + increment: Patch + prevent-increment-of-merged-branch-version: true + track-merge-target: false + regex: ^master$|^main$ + source-branches: + - release + tracks-release-branches: false + is-release-branch: false + is-main-branch: true + pre-release-weight: 55000 + release: + label: beta + increment: None + prevent-increment-of-merged-branch-version: true + track-merge-target: false + regex: ^releases?[/-] + source-branches: + - main + - release + tracks-release-branches: false + is-release-branch: true + is-main-branch: false + pre-release-weight: 30000 + feature: + mode: ContinuousDelivery + label: '{BranchName}' + increment: Inherit + regex: ^features?[/-](?.+) + source-branches: + - main + - release + - feature + pre-release-weight: 30000 + pull-request: + mode: ContinuousDelivery + label: PullRequest + increment: Inherit + label-number-pattern: '[/-](?\d+)' + regex: ^(pull|pull\-requests|pr)[/-] + source-branches: + - main + - release + - feature + pre-release-weight: 30000 + unknown: + mode: ContinuousDelivery + label: '{BranchName}' + increment: Inherit + regex: (?.*) + source-branches: + - main + - release + - feature + - pull-request +ignore: + sha: [] +mode: ContinuousDelivery +label: '{BranchName}' +increment: Inherit +prevent-increment-of-merged-branch-version: false +track-merge-target: false +track-merge-message: true +commit-message-incrementing: Enabled +regex: '' +tracks-release-branches: false +is-release-branch: false +is-main-branch: false diff --git a/src/GitVersion.Core.Tests/IntegrationTests/ComparingTheBehaviorOfDifferentVersioningModes.cs b/src/GitVersion.Core.Tests/IntegrationTests/ComparingTheBehaviorOfDifferentVersioningModes.cs index 88eeb91400..fb234bb458 100644 --- a/src/GitVersion.Core.Tests/IntegrationTests/ComparingTheBehaviorOfDifferentVersioningModes.cs +++ b/src/GitVersion.Core.Tests/IntegrationTests/ComparingTheBehaviorOfDifferentVersioningModes.cs @@ -11,7 +11,7 @@ namespace GitVersion.Core.Tests.IntegrationTests; [TestFixture] internal class ComparingTheBehaviorOfDifferentDeploymentModes { - private static readonly GitHubFlowConfigurationBuilder configurationBuilder = GitHubFlowConfigurationBuilder.New + private static GitHubFlowConfigurationBuilder GetConfigurationBuilder() => GitHubFlowConfigurationBuilder.New .WithLabel(null) .WithBranch("main", _ => _ .WithIncrement(IncrementStrategy.Patch).WithLabel(null) @@ -19,25 +19,25 @@ internal class ComparingTheBehaviorOfDifferentDeploymentModes .WithIncrement(IncrementStrategy.Inherit).WithLabel("{BranchName}") ); - private static readonly IGitVersionConfiguration trunkBased = configurationBuilder - .WithDeploymentMode(DeploymentMode.TrunkBased) + private static readonly IGitVersionConfiguration trunkBased = GetConfigurationBuilder() + .WithVersionStrategy(VersionStrategies.TrunkBased) .WithBranch("main", _ => _.WithIsMainBranch(true).WithDeploymentMode(DeploymentMode.ContinuousDeployment)) .WithBranch("feature", _ => _.WithIsMainBranch(false).WithDeploymentMode(DeploymentMode.ContinuousDelivery)) .Build(); - private static readonly IGitVersionConfiguration continuousDeployment = configurationBuilder + private static readonly IGitVersionConfiguration continuousDeployment = GetConfigurationBuilder() .WithDeploymentMode(DeploymentMode.ContinuousDeployment) .WithBranch("main", _ => _.WithIsMainBranch(true).WithDeploymentMode(DeploymentMode.ContinuousDeployment)) .WithBranch("feature", _ => _.WithIsMainBranch(false).WithDeploymentMode(DeploymentMode.ContinuousDeployment)) .Build(); - private static readonly IGitVersionConfiguration continuousDelivery = configurationBuilder + private static readonly IGitVersionConfiguration continuousDelivery = GetConfigurationBuilder() .WithDeploymentMode(DeploymentMode.ContinuousDelivery) .WithBranch("main", _ => _.WithIsMainBranch(true).WithDeploymentMode(DeploymentMode.ContinuousDelivery)) .WithBranch("feature", _ => _.WithIsMainBranch(false).WithDeploymentMode(DeploymentMode.ContinuousDelivery)) .Build(); - private static readonly IGitVersionConfiguration manualDeployment = configurationBuilder + private static readonly IGitVersionConfiguration manualDeployment = GetConfigurationBuilder() .WithDeploymentMode(DeploymentMode.ManualDeployment) .WithBranch("main", _ => _.WithIsMainBranch(true).WithDeploymentMode(DeploymentMode.ManualDeployment)) .WithBranch("feature", _ => _.WithIsMainBranch(false).WithDeploymentMode(DeploymentMode.ManualDeployment)) diff --git a/src/GitVersion.Core.Tests/IntegrationTests/TrunkBasedDevelopmentScenarios.cs b/src/GitVersion.Core.Tests/IntegrationTests/TrunkBasedDevelopmentScenarios.cs index 06f72983f5..80be294775 100644 --- a/src/GitVersion.Core.Tests/IntegrationTests/TrunkBasedDevelopmentScenarios.cs +++ b/src/GitVersion.Core.Tests/IntegrationTests/TrunkBasedDevelopmentScenarios.cs @@ -8,7 +8,7 @@ namespace GitVersion.Core.Tests.IntegrationTests; public class TrunkBasedDevelopmentScenarios : TestBase { private static GitFlowConfigurationBuilder GetConfigurationBuilder() => GitFlowConfigurationBuilder.New - .WithDeploymentMode(DeploymentMode.TrunkBased) + .WithVersionStrategy(VersionStrategies.TrunkBased) .WithBranch("main", builder => builder .WithIsMainBranch(true).WithIncrement(IncrementStrategy.Patch) .WithDeploymentMode(DeploymentMode.ContinuousDeployment) @@ -511,7 +511,7 @@ public void MergingFeatureBranchThatIncrementsMinorNumberIncrementsMinorVersionO public void VerifyIncrementConfigIsHonoured() { var minorIncrementConfig = GitFlowConfigurationBuilder.New - .WithDeploymentMode(DeploymentMode.TrunkBased) + .WithVersionStrategy(VersionStrategies.TrunkBased) .WithBranch("main", builder => builder .WithDeploymentMode(DeploymentMode.ContinuousDeployment) .WithIncrement(IncrementStrategy.None) diff --git a/src/GitVersion.Core.Tests/IntegrationTests/VersionBumpingScenarios.cs b/src/GitVersion.Core.Tests/IntegrationTests/VersionBumpingScenarios.cs index a977c7f0eb..c0e322fe86 100644 --- a/src/GitVersion.Core.Tests/IntegrationTests/VersionBumpingScenarios.cs +++ b/src/GitVersion.Core.Tests/IntegrationTests/VersionBumpingScenarios.cs @@ -86,7 +86,7 @@ public void CanUseConventionalCommitsToBumpVersion(string commitMessage, string .WithMinorVersionBumpMessage("^(feat)(\\([\\w\\s-]*\\))?:") // For future debugging of this regex: https://regex101.com/r/oFpqxA/2 .WithPatchVersionBumpMessage("^(build|chore|ci|docs|fix|perf|refactor|revert|style|test)(\\([\\w\\s-]*\\))?:") - .WithDeploymentMode(DeploymentMode.TrunkBased) + .WithVersionStrategy(VersionStrategies.TrunkBased) .WithBranch("main", builder => builder.WithDeploymentMode(DeploymentMode.ContinuousDeployment)) .Build(); diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitFlow+GivenADevelopBranchWithOneCommitMergedToMainWhen.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitFlow+GivenADevelopBranchWithOneCommitMergedToMainWhen.cs new file mode 100644 index 0000000000..1f9ebc1ac3 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitFlow+GivenADevelopBranchWithOneCommitMergedToMainWhen.cs @@ -0,0 +1,98 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenADevelopBranchWithOneCommitMergedToMainWhen + { + private EmptyRepositoryFixture? fixture; + + private static GitFlowConfigurationBuilder TrunkBasedBuilder => GitFlowConfigurationBuilder.New.WithLabel(null) + .WithVersionStrategy(VersionStrategies.TrunkBased) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("develop", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // * 55 minutes ago (HEAD -> main) + // |\ + // | * 56 minutes ago (develop) + // |/ + // * 58 minutes ago + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.BranchTo("develop"); + fixture.MakeACommit("B"); + fixture.MergeTo("main"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, ExpectedResult = "0.0.0-alpha.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, ExpectedResult = "0.0.1-alpha.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, ExpectedResult = "0.1.0-alpha.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, ExpectedResult = "1.0.0-alpha.1+2")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, ExpectedResult = "0.0.1-alpha.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, ExpectedResult = "0.0.2-alpha.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, ExpectedResult = "0.1.0-alpha.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, ExpectedResult = "1.0.0-alpha.1+2")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, ExpectedResult = "0.1.0-alpha.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, ExpectedResult = "0.1.1-alpha.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, ExpectedResult = "0.2.0-alpha.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, ExpectedResult = "1.0.0-alpha.1+2")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, ExpectedResult = "1.0.0-alpha.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, ExpectedResult = "1.0.1-alpha.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, ExpectedResult = "1.1.0-alpha.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, ExpectedResult = "2.0.0-alpha.1+2")] + public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("develop", _ => _.WithIncrement(increment)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, ExpectedResult = "1.0.0-1+2")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, ExpectedResult = "0.0.1-2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, ExpectedResult = "1.0.0-1+2")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, ExpectedResult = "0.1.0-2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, ExpectedResult = "0.1.1-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, ExpectedResult = "1.0.0-1+2")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, ExpectedResult = "1.0.0-2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, ExpectedResult = "1.0.1-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, ExpectedResult = "1.1.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, ExpectedResult = "2.0.0-1+2")] + public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("develop", _ => _.WithIncrement(increment)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitFlow+GivenADevelopBranchWithOneCommitMergedToMainWhenMergedCommitTaggedAsStable.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitFlow+GivenADevelopBranchWithOneCommitMergedToMainWhenMergedCommitTaggedAsStable.cs new file mode 100644 index 0000000000..b1b05c1dc4 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitFlow+GivenADevelopBranchWithOneCommitMergedToMainWhenMergedCommitTaggedAsStable.cs @@ -0,0 +1,100 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenADevelopBranchWithOneCommitMergedToMainWhenMergedCommitTaggedAsStable + { + private EmptyRepositoryFixture? fixture; + + private static GitFlowConfigurationBuilder TrunkBasedBuilder => GitFlowConfigurationBuilder.New.WithLabel(null) + .WithVersionStrategy(VersionStrategies.TrunkBased) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("develop", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // * 55 minutes ago (tag: 1.0.0, main) + // |\ + // | * 56 minutes ago (HEAD -> develop) + // |/ + // * 58 minutes ago + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.BranchTo("develop"); + fixture.MakeACommit("B"); + fixture.MergeTo("main"); + fixture.ApplyTag("1.0.0"); + fixture.Checkout("develop"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, ExpectedResult = "1.0.0-alpha.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, ExpectedResult = "1.0.1-alpha.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, ExpectedResult = "1.1.0-alpha.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, ExpectedResult = "2.0.0-alpha.1+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, ExpectedResult = "1.0.0-alpha.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, ExpectedResult = "1.0.1-alpha.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, ExpectedResult = "1.1.0-alpha.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, ExpectedResult = "2.0.0-alpha.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, ExpectedResult = "1.0.0-alpha.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, ExpectedResult = "1.0.1-alpha.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, ExpectedResult = "1.1.0-alpha.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, ExpectedResult = "2.0.0-alpha.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, ExpectedResult = "1.0.0-alpha.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, ExpectedResult = "1.0.1-alpha.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, ExpectedResult = "1.1.0-alpha.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, ExpectedResult = "2.0.0-alpha.1+0")] + public string GetVersionWithTrackMergeTargetOnDevelop(IncrementStrategy incrementOnMain, IncrementStrategy increment) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("develop", _ => _.WithIncrement(increment).WithTrackMergeTarget(true)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, ExpectedResult = "0.0.0-alpha.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, ExpectedResult = "0.0.1-alpha.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, ExpectedResult = "0.1.0-alpha.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, ExpectedResult = "1.0.0-alpha.1+2")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, ExpectedResult = "0.0.0-alpha.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, ExpectedResult = "0.0.1-alpha.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, ExpectedResult = "0.1.0-alpha.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, ExpectedResult = "1.0.0-alpha.1+2")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, ExpectedResult = "0.0.0-alpha.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, ExpectedResult = "0.0.1-alpha.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, ExpectedResult = "0.1.0-alpha.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, ExpectedResult = "1.0.0-alpha.1+2")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, ExpectedResult = "0.0.0-alpha.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, ExpectedResult = "0.0.1-alpha.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, ExpectedResult = "0.1.0-alpha.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, ExpectedResult = "1.0.0-alpha.1+2")] + public string GetVersionWithNoTrackMergeTargetOnDevelop(IncrementStrategy incrementOnMain, IncrementStrategy increment) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("develop", _ => _.WithIncrement(increment).WithTrackMergeTarget(false)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithAMergeCommitFromMainMergedBackToMainWhen.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithAMergeCommitFromMainMergedBackToMainWhen.cs new file mode 100644 index 0000000000..11a09e3a82 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithAMergeCommitFromMainMergedBackToMainWhen.cs @@ -0,0 +1,236 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAFeatureBranchWithAMergeCommitFromMainMergedBackToMainWhen + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New.WithLabel(null) + .WithVersionStrategy(VersionStrategies.TrunkBased) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // * 52 minutes ago (HEAD -> main) + // |\ + // | * 53 minutes ago (feature/foo) + // | |\ + // | |/ + // |/| + // C | 54 minutes ago + // | B 56 minutes ago + // |/ + // A 58 minutes ago + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.BranchTo("feature/foo"); + fixture.MakeACommit("B"); + fixture.Checkout("main"); + fixture.MakeACommit("C"); + fixture.Checkout("main"); + fixture.MergeTo("feature/foo"); + fixture.MergeTo("main", removeBranchAfterMerging: true); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-3+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-3+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.3+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.3+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.3+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.3+3")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.3-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+3")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-2+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.2+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.3.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.2+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+3")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-2+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.2+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.2+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+3")] + public string GetVersion(IncrementStrategy increment, IncrementStrategy incrementOnFeature, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label)) + .WithBranch("feature", _ => _.WithIncrement(incrementOnFeature)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-3+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-3+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.3+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.3+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.3+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.3+3")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.3-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.3-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.3-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.3-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.3-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+3")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.3.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.3.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.3.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.3.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.3.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.3.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.3.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.3.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.3.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+3")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "3.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "3.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "3.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "3.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "3.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "3.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "3.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "3.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "3.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "3.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "3.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "3.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+3")] + public string GetVersionWithPreventIncrementOfMergedBranchVersionFalseOnMain( + IncrementStrategy increment, IncrementStrategy incrementOnFeature, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label).WithPreventIncrementOfMergedBranchVersion(false)) + .WithBranch("feature", _ => _.WithIncrement(incrementOnFeature)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithAMergeCommitFromMainWhen.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithAMergeCommitFromMainWhen.cs new file mode 100644 index 0000000000..77b55990fa --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithAMergeCommitFromMainWhen.cs @@ -0,0 +1,175 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAFeatureBranchWithAMergeCommitFromMainWhen + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New.WithLabel(null) + .WithVersionStrategy(VersionStrategies.TrunkBased) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // * 53 minutes ago (HEAD -> feature/foo) + // |\ + // | B 54 minutes ago + // C | 56 minutes ago (main) + // |/ + // A 58 minutes ago + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.BranchTo("feature/foo"); + fixture.MakeACommit("B"); + fixture.Checkout("main"); + fixture.MakeACommit("C"); + fixture.MergeTo("feature/foo"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, ExpectedResult = "0.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, ExpectedResult = "0.0.0-foo.1+2")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, ExpectedResult = "0.0.3-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, ExpectedResult = "0.0.3-foo.1+2")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, ExpectedResult = "0.2.1-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, ExpectedResult = "0.3.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, ExpectedResult = "0.3.0-foo.1+2")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, ExpectedResult = "2.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, ExpectedResult = "2.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, ExpectedResult = "3.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, ExpectedResult = "3.0.0-foo.1+2")] + public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, ExpectedResult = "0.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, ExpectedResult = "0.0.0-foo.1+2")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, ExpectedResult = "0.0.3-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, ExpectedResult = "0.0.3-foo.1+2")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, ExpectedResult = "0.2.1-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, ExpectedResult = "0.3.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, ExpectedResult = "0.3.0-foo.1+2")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, ExpectedResult = "2.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, ExpectedResult = "2.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, ExpectedResult = "3.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, ExpectedResult = "3.0.0-foo.1+2")] + public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, ExpectedResult = "0.0.0-foo.3+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, ExpectedResult = "0.0.0-foo.3+2")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, ExpectedResult = "0.0.2-foo.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, ExpectedResult = "0.0.3-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, ExpectedResult = "0.0.3-foo.1+2")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, ExpectedResult = "0.2.0-foo.2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, ExpectedResult = "0.2.1-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, ExpectedResult = "0.3.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, ExpectedResult = "0.3.0-foo.1+2")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, ExpectedResult = "2.0.0-foo.2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, ExpectedResult = "2.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, ExpectedResult = "2.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, ExpectedResult = "3.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, ExpectedResult = "3.0.0-foo.1+2")] + public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, ExpectedResult = "0.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, ExpectedResult = "0.0.0-foo.1+2")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, ExpectedResult = "0.0.3-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, ExpectedResult = "0.0.3-foo.1+2")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, ExpectedResult = "0.2.1-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, ExpectedResult = "0.3.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, ExpectedResult = "0.3.0-foo.1+2")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, ExpectedResult = "2.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, ExpectedResult = "2.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, ExpectedResult = "3.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, ExpectedResult = "3.0.0-foo.1+2")] + public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhen.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhen.cs new file mode 100644 index 0000000000..36fbfc8383 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhen.cs @@ -0,0 +1,488 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAFeatureBranchWithOneCommitBranchedFromMainWhen + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 47 minutes ago (HEAD -> feature/foo) + // A 51 minutes ago (main) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.BranchTo("feature/foo"); + fixture.MakeACommit("B"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.2+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-bar.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitAHasBumpMessageMajor.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitAHasBumpMessageMajor.cs new file mode 100644 index 0000000000..656cc1d362 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitAHasBumpMessageMajor.cs @@ -0,0 +1,1409 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitAHasBumpMessageMajor + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 47 minutes ago (HEAD -> feature/foo) + // A 51 minutes ago (main) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A +semver: major"); + fixture.BranchTo("feature/foo"); + fixture.MakeACommit("B"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithNoLabelAndDisabledMessageIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithNoLabelAndMergeMessageOnlyIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + + public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithEmptyLabelAndDisabledMessageIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithEmptyLabelAndMergeMessageOnlyIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.2+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.2+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelFooAndDisabledMergeMessageIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo") + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.2+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelFooAndMergeMessageOnlyIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo") + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-bar.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelBarAndDisabledMergeMessageIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar") + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-bar.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelBarAndMergeMessageOnlyIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar") + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitAHasBumpMessageMinor.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitAHasBumpMessageMinor.cs new file mode 100644 index 0000000000..2646ecd4b5 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitAHasBumpMessageMinor.cs @@ -0,0 +1,1409 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitAHasBumpMessageMinor + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 47 minutes ago (HEAD -> feature/foo) + // A 51 minutes ago (main) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A +semver: minor"); + fixture.BranchTo("feature/foo"); + fixture.MakeACommit("B"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithNoLabelAndDisabledMessageIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithNoLabelAndMergeMessageOnlyIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + + public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithEmptyLabelAndDisabledMessageIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithEmptyLabelAndMergeMessageOnlyIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.0-foo.2+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.2+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelFooAndDisabledMergeMessageIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo") + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.2+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelFooAndMergeMessageOnlyIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo") + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-bar.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelBarAndDisabledMergeMessageIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar") + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-bar.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelBarAndMergeMessageOnlyIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar") + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitAHasBumpMessagePatch.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitAHasBumpMessagePatch.cs new file mode 100644 index 0000000000..8245ca27ea --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitAHasBumpMessagePatch.cs @@ -0,0 +1,1408 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitAHasBumpMessagePatch + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 47 minutes ago (HEAD -> feature/foo) + // A 51 minutes ago (main) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A +semver: patch"); + fixture.BranchTo("feature/foo"); + fixture.MakeACommit("B"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithNoLabelAndDisabledMessageIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithNoLabelAndMergeMessageOnlyIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithEmptyLabelAndDisabledMessageIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithEmptyLabelAndMergeMessageOnlyIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.1-foo.2+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.2+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelFooAndDisabledMergeMessageIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo") + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.2+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelFooAndMergeMessageOnlyIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo") + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.1-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.1-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-bar.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-bar.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelBarAndDisabledMergeMessageIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar") + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-bar.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelBarAndMergeMessageOnlyIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar") + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitATaggedAsPreRelease.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitATaggedAsPreRelease.cs new file mode 100644 index 0000000000..096e63cb84 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitATaggedAsPreRelease.cs @@ -0,0 +1,489 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitATaggedAsPreRelease + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 47 minutes ago (HEAD -> feature/foo) + // A 51 minutes ago (main) (tag 0.0.0-4) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.ApplyTag("0.0.0-4"); + fixture.BranchTo("feature/foo"); + fixture.MakeACommit("B"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.2+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-bar.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitATaggedAsPreReleaseBar.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitATaggedAsPreReleaseBar.cs new file mode 100644 index 0000000000..23403c1a51 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitATaggedAsPreReleaseBar.cs @@ -0,0 +1,489 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitATaggedAsPreReleaseBar + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 47 minutes ago (HEAD -> feature/foo) + // A 51 minutes ago (main) (tag 0.0.0-bar) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.ApplyTag("0.0.0-bar"); + fixture.BranchTo("feature/foo"); + fixture.MakeACommit("B"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.1-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.1-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.2+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.1-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.1-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitATaggedAsPreReleaseFoo.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitATaggedAsPreReleaseFoo.cs new file mode 100644 index 0000000000..ae40d134d1 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitATaggedAsPreReleaseFoo.cs @@ -0,0 +1,489 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitATaggedAsPreReleaseFoo + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 47 minutes ago (HEAD -> feature/foo) + // A 51 minutes ago (main) (tag 0.0.0-foo.4) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.ApplyTag("0.0.0-foo.4"); + fixture.BranchTo("feature/foo"); + fixture.MakeACommit("B"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-bar.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitATaggedAsStable.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitATaggedAsStable.cs new file mode 100644 index 0000000000..e21ddc34af --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitATaggedAsStable.cs @@ -0,0 +1,493 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitATaggedAsStable + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 47 minutes ago (HEAD -> feature/foo) + // A 51 minutes ago (main) (tag 0.0.0) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.ApplyTag("0.0.0"); + fixture.BranchTo("feature/foo"); + fixture.MakeACommit("B"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + public string GetVersionWithNoLabelOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + public string GetVersionWithEmptyLabelOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + public string GetVersionWithLabelFooOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + public string GetVersionWithLabelBarOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitBHasBumpMessageMajor.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitBHasBumpMessageMajor.cs new file mode 100644 index 0000000000..fea9c49462 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitBHasBumpMessageMajor.cs @@ -0,0 +1,1416 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitBHasBumpMessageMajor + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 47 minutes ago (HEAD -> feature/foo) + // A 51 minutes ago (main) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.BranchTo("feature/foo"); + fixture.MakeACommit("B +semver: major"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithNoLabelAndDisabledMessageIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _ + .WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithNoLabelAndMergeMessageOnlyIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _ + .WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithEmptyLabelAndDisabledMessageIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _ + .WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithEmptyLabelAndMergeMessageOnlyIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _ + .WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.2+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelFooAndDisabledMessageIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _ + .WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.2+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelFooAndMergeMessageOnlyIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _ + .WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-bar.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelBarAndDisabledMessageIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _ + .WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-bar.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelBarAndMergeMessageOnlyIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _ + .WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitBHasBumpMessageMinor.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitBHasBumpMessageMinor.cs new file mode 100644 index 0000000000..0230968690 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitBHasBumpMessageMinor.cs @@ -0,0 +1,1416 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitBHasBumpMessageMinor + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 47 minutes ago (HEAD -> feature/foo) + // A 51 minutes ago (main) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.BranchTo("feature/foo"); + fixture.MakeACommit("B +semver: minor"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithNoLabelAndDisabledMessageIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _ + .WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithNoLabelAndMergeMessageOnlyIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _ + .WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithEmptyLabelAndDisabledMessageIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _ + .WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithEmptyLabelAndMergeMessageOnlyIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _ + .WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.2+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelFooAndDisabledMessageIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _ + .WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.2+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelFooAndMergeMessageOnlyIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _ + .WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-bar.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelBarAndDisabledMessageIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _ + .WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-bar.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelBarAndMergeMessageOnlyIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _ + .WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitBHasBumpMessagePatch.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitBHasBumpMessagePatch.cs new file mode 100644 index 0000000000..7797492706 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitBHasBumpMessagePatch.cs @@ -0,0 +1,1416 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitBHasBumpMessagePatch + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 47 minutes ago (HEAD -> feature/foo) + // A 51 minutes ago (main) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.BranchTo("feature/foo"); + fixture.MakeACommit("B +semver: patch"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithNoLabelAndDisabledMessageIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _ + .WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithNoLabelAndMergeMessageOnlyIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _ + .WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithEmptyLabelAndDisabledMessageIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _ + .WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithEmptyLabelAndMergeMessageOnlyIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _ + .WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.2+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelFooAndDisabledMessageIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _ + .WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.2+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelFooAndMergeMessageOnlyIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _ + .WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-bar.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelBarAndDisabledMessageIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _ + .WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-bar.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelBarAndMergeMessageOnlyIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _ + .WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitBTaggedAsPreRelease.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitBTaggedAsPreRelease.cs new file mode 100644 index 0000000000..fd3c88649e --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitBTaggedAsPreRelease.cs @@ -0,0 +1,489 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitBTaggedAsPreRelease + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 47 minutes ago (HEAD -> feature/foo) (tag 0.0.0-4) + // A 51 minutes ago (main) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.BranchTo("feature/foo"); + fixture.MakeACommit("B"); + fixture.ApplyTag("0.0.0-4"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.2+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitBTaggedAsPreReleaseBar.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitBTaggedAsPreReleaseBar.cs new file mode 100644 index 0000000000..220cb1b99f --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitBTaggedAsPreReleaseBar.cs @@ -0,0 +1,489 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitBTaggedAsPreReleaseBar + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 47 minutes ago (HEAD -> feature/foo) (tag 0.0.0-bar) + // A 51 minutes ago (main) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.BranchTo("feature/foo"); + fixture.MakeACommit("B"); + fixture.ApplyTag("0.0.0-bar"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.2+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+1")] + public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitBTaggedAsPreReleaseFoo.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitBTaggedAsPreReleaseFoo.cs new file mode 100644 index 0000000000..dc2ac981d0 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitBTaggedAsPreReleaseFoo.cs @@ -0,0 +1,489 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitBTaggedAsPreReleaseFoo + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 47 minutes ago (HEAD -> feature/foo) (tag 0.0.0-foo.4) + // A 51 minutes ago (main) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.BranchTo("feature/foo"); + fixture.MakeACommit("B"); + fixture.ApplyTag("0.0.0-foo.4"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.2+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitBTaggedAsStable.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitBTaggedAsStable.cs new file mode 100644 index 0000000000..ffcae22f52 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitBTaggedAsStable.cs @@ -0,0 +1,877 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAFeatureBranchWithOneCommitBranchedFromMainWhenCommitBTaggedAsStable + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 47 minutes ago (HEAD -> feature/foo) (tag 0.0.0) + // A 51 minutes ago (main) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.BranchTo("feature/foo"); + fixture.MakeACommit("B"); + fixture.ApplyTag("0.0.0"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0")] + public string GetVersionWithNoLabelOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + 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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+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.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+0")] + [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( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0")] + public string GetVersionWithEmptyLabelOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + 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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+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.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+0")] + [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( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0")] + public string GetVersionWithLabelFooOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + 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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+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.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+0")] + [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( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0")] + public string GetVersionWithLabelBarOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + 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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+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.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+0")] + [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( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitMergedToMainWhen.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitMergedToMainWhen.cs new file mode 100644 index 0000000000..18b630ef92 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitMergedToMainWhen.cs @@ -0,0 +1,956 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAFeatureBranchWithOneCommitMergedToMainWhen + { + private EmptyRepositoryFixture? fixture; + + private static GitFlowConfigurationBuilder TrunkBasedBuilder => GitFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // * 54 minutes ago (HEAD -> main) + // |\ + // | B 56 minutes ago (feature/foo) + // |/ + // A 58 minutes ago + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.BranchTo("feature/foo"); + fixture.MakeACommit("B"); + fixture.MergeTo("main"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+2")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+2")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+2")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+2")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+2")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+2")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+2")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+2")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + public string GetVersionWithLabelNullAndPreventIncrementOfMergedBranchVersionFalseOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null).WithPreventIncrementOfMergedBranchVersion(false)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+2")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+2")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-1+2")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-1+2")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-1+2")] + public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+2")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+2")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-1+2")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-1+2")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-1+2")] + public string GetVersionWithEmptyLabelAndPreventIncrementOfMergedBranchVersionFalseOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty).WithPreventIncrementOfMergedBranchVersion(false)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-foo.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-foo.2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-foo.2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+2")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-foo.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-foo.2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-foo.2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-foo.1+2")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+2")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-foo.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-foo.2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-foo.2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-foo.1+2")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+2")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-foo.1+2")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+2")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-foo.1+2")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + public string GetVersionWithLabelFooAndPreventIncrementOfMergedBranchVersionFalseOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo").WithPreventIncrementOfMergedBranchVersion(false)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-bar.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-bar.2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-bar.2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+2")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-bar.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-bar.2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-bar.2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-bar.1+2")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-bar.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-bar.2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-bar.2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-bar.1+2")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+2")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-bar.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-bar.2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-bar.2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-bar.1+2")] + public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+2")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-bar.1+2")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-bar.1+2")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+2")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-bar.1+2")] + public string GetVersionWithLabelBarAndPreventIncrementOfMergedBranchVersionFalseOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar").WithPreventIncrementOfMergedBranchVersion(false)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitMergedToMainWhenCommitBTaggedAsPreRelease.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitMergedToMainWhenCommitBTaggedAsPreRelease.cs new file mode 100644 index 0000000000..a20c6630e0 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitMergedToMainWhenCommitBTaggedAsPreRelease.cs @@ -0,0 +1,950 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAFeatureBranchWithOneCommitMergedToMainWhenCommitBTaggedAsPreRelease + { + private EmptyRepositoryFixture? fixture; + + private static GitFlowConfigurationBuilder TrunkBasedBuilder => GitFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + fixture = new EmptyRepositoryFixture("main"); + + // * 54 minutes ago (HEAD -> main) + // |\ + // | B 56 minutes ago (feature/foo) (tag 0.0.0-4) + // |/ + // A 58 minutes ago + + fixture.MakeACommit("A"); + fixture.BranchTo("feature/foo"); + fixture.MakeACommit("B"); + fixture.ApplyTag("0.0.0-4"); + fixture.MergeTo("main"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+2")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+2")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+2")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+2")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+2")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+2")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + public string GetVersionWithLabelNullAndPreventIncrementOfMergedBranchVersionFalseOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null).WithPreventIncrementOfMergedBranchVersion(false)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-5+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-5+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-5+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-5+1")] + public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-5+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-5+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-5+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-5+1")] + + public string GetVersionWithEmptyLabelAndPreventIncrementOfMergedBranchVersionFalseOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty).WithPreventIncrementOfMergedBranchVersion(false)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.2+2")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-foo.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-foo.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-foo.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+2")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-foo.2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-foo.2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-foo.2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+2")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-foo.2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-foo.2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-foo.2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.2+2")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+2")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+2")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + public string GetVersionWithLabelFooAndPreventIncrementOfMergedBranchVersionFalseOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo").WithPreventIncrementOfMergedBranchVersion(false)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-bar.2+2")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-bar.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-bar.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-bar.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-bar.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-bar.1+2")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-bar.2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-bar.2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-bar.2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-bar.2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-bar.1+2")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-bar.2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-bar.2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-bar.2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-bar.2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-bar.1+2")] + public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-bar.2+2")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-bar.1+2")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-bar.1+2")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-bar.1+2")] + public string GetVersionWithLabelBarAndPreventIncrementOfMergedBranchVersionFalseOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar").WithPreventIncrementOfMergedBranchVersion(false)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitMergedToMainWhenCommitBTaggedAsPreReleaseBar.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitMergedToMainWhenCommitBTaggedAsPreReleaseBar.cs new file mode 100644 index 0000000000..4aba8e8238 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitMergedToMainWhenCommitBTaggedAsPreReleaseBar.cs @@ -0,0 +1,949 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAFeatureBranchWithOneCommitMergedToMainWhenCommitBTaggedAsPreReleaseBar + { + private EmptyRepositoryFixture? fixture; + + private static GitFlowConfigurationBuilder TrunkBasedBuilder => GitFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + fixture = new EmptyRepositoryFixture("main"); + + // * 55 minutes ago (HEAD -> main) + // |\ + // | B 56 minutes ago (feature/foo) (tag 0.0.0-bar) + // |/ + // A 58 minutes ago + + fixture.MakeACommit("A"); + fixture.BranchTo("feature/foo"); + fixture.MakeACommit("B"); + fixture.ApplyTag("0.0.0-bar"); + fixture.MergeTo("main"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+2")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+2")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+2")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+2")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+2")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+2")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + public string GetVersionWithLabelNullAndPreventIncrementOfMergedBranchVersionFalseOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null).WithPreventIncrementOfMergedBranchVersion(false)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-2+2")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-1+2")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-1+2")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-1+2")] + public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-2+2")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-1+2")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-1+2")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-1+2")] + public string GetVersionWithEmptyLabelAndPreventIncrementOfMergedBranchVersionFalseOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty).WithPreventIncrementOfMergedBranchVersion(false)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.2+2")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-foo.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-foo.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-foo.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+2")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-foo.2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-foo.2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-foo.2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+2")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-foo.2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-foo.2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-foo.2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.2+2")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+2")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+2")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + public string GetVersionWithLabelFooAndPreventIncrementOfMergedBranchVersionFalseOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo").WithPreventIncrementOfMergedBranchVersion(false)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-bar+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-bar+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-bar+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-bar+1")] + public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-bar+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-bar+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-bar+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-bar+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-bar+1")] + public string GetVersionWithLabelBarAndPreventIncrementOfMergedBranchVersionFalseOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar").WithPreventIncrementOfMergedBranchVersion(false)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitMergedToMainWhenCommitBTaggedAsPreReleaseFoo.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitMergedToMainWhenCommitBTaggedAsPreReleaseFoo.cs new file mode 100644 index 0000000000..818cff1306 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitMergedToMainWhenCommitBTaggedAsPreReleaseFoo.cs @@ -0,0 +1,949 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAFeatureBranchWithOneCommitMergedToMainWhenCommitBTaggedAsPreReleaseFoo + { + private EmptyRepositoryFixture? fixture; + + private static GitFlowConfigurationBuilder TrunkBasedBuilder => GitFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + fixture = new EmptyRepositoryFixture("main"); + + // * 55 minutes ago (HEAD -> main) + // |\ + // | B 56 minutes ago (feature/foo) (tag 0.0.0-foo.4) + // |/ + // A 58 minutes ago + + fixture.MakeACommit("A"); + fixture.BranchTo("feature/foo"); + fixture.MakeACommit("B"); + fixture.ApplyTag("0.0.0-foo.4"); + fixture.MergeTo("main"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + public string GetVersionWithLabelNullAndPreventIncrementOfMergedBranchVersionFalseOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null).WithPreventIncrementOfMergedBranchVersion(false)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-2+2")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-1+2")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-1+2")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-1+2")] + public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-2+2")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-1+2")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-1+2")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-1+2")] + public string GetVersionWithEmptyLabelAndPreventIncrementOfMergedBranchVersionFalseOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty).WithPreventIncrementOfMergedBranchVersion(false)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.5+1")] + public string GetVersionWithLabelFooAndPreventIncrementOfMergedBranchVersionFalseOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo").WithPreventIncrementOfMergedBranchVersion(false)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-bar.2+2")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-bar.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-bar.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-bar.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-bar.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-bar.1+2")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-bar.2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-bar.2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-bar.2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-bar.2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-bar.1+2")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-bar.2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-bar.2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-bar.2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-bar.2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-bar.1+2")] + public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-bar.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-bar.2+2")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-bar.1+2")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-bar.1+2")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-bar.1+2")] + public string GetVersionWithLabelBarAndPreventIncrementOfMergedBranchVersionFalseOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar").WithPreventIncrementOfMergedBranchVersion(false)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitMergedToMainWhenCommitBTaggedAsStable.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitMergedToMainWhenCommitBTaggedAsStable.cs new file mode 100644 index 0000000000..b4d7099776 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitMergedToMainWhenCommitBTaggedAsStable.cs @@ -0,0 +1,949 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAFeatureBranchWithOneCommitMergedToMainWhenCommitBTaggedAsStable + { + private EmptyRepositoryFixture? fixture; + + private static GitFlowConfigurationBuilder TrunkBasedBuilder => GitFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + fixture = new EmptyRepositoryFixture("main"); + + // * 55 minutes ago (HEAD -> main) + // |\ + // | B 56 minutes ago (feature/foo) (tag 0.0.0) + // |/ + // A 58 minutes ago + + fixture.MakeACommit("A"); + fixture.BranchTo("feature/foo"); + fixture.MakeACommit("B"); + fixture.ApplyTag("0.0.0"); + fixture.MergeTo("main"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + public string GetVersionWithLabelNullAndPreventIncrementOfMergedBranchVersionFalseOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null).WithPreventIncrementOfMergedBranchVersion(false)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.1-1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.0-1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-1+1")] + public string GetVersionWithEmpyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.1-1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.0-1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-1+1")] + public string GetVersionWithEmpyLabelAndPreventIncrementOfMergedBranchVersionFalseOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty).WithPreventIncrementOfMergedBranchVersion(false)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.1-foo.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.0-foo.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+1")] + public string GetVersionWithLabelFooAndPreventIncrementOfMergedBranchVersionFalseOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo").WithPreventIncrementOfMergedBranchVersion(false)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-bar.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.1-bar.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.0-bar.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-bar.1+1")] + public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-bar.1+1")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.1-bar.1+1")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.0-bar.1+1")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-bar.1+1")] + public string GetVersionWithLabelBarAndPreventIncrementOfMergedBranchVersionFalseOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar").WithPreventIncrementOfMergedBranchVersion(false)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitMergedToMainWithOneCommitBranchedToFeatureWhen.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitMergedToMainWithOneCommitBranchedToFeatureWhen.cs new file mode 100644 index 0000000000..8a6aaae56a --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitMergedToMainWithOneCommitBranchedToFeatureWhen.cs @@ -0,0 +1,961 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAFeatureBranchWithOneCommitMergedToMainWithOneCommitBranchedToFeatureWhen + { + private EmptyRepositoryFixture? fixture; + + private static GitFlowConfigurationBuilder TrunkBasedBuilder => GitFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // * 53 minutes ago (HEAD -> feature/foo) (main) + // |\ + // C | 54 minutes ago + // | B 56 minutes ago + // |/ + // A 58 minutes ago + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.BranchTo("feature/foo"); + fixture.MakeACommit("B"); + fixture.Checkout("main"); + fixture.MakeACommit("C"); + fixture.Checkout("feature/foo"); + fixture.MergeTo("main", removeBranchAfterMerging: true); + fixture.BranchTo("feature/foo"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-4+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-4+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.2-3+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-3+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.2-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.4.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.4.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-3+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.2-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.2.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "4.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "4.0.0-1+0")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-4+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-4+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-3+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-3+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.2-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.4.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.4.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-3+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.2-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.2.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "4.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "4.0.0-1+0")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.2-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.4.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.4.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "4.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "4.0.0-foo.1+0")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.2-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.4.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.4.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "4.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "4.0.0-bar.1+0")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.2-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.4.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.4.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "4.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "4.0.0-foo.1+0")] + public string GetVersionWithLabelNullOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-4+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-4+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.3-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.3.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.3.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.4.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.4.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "3.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "3.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "3.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "4.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "4.0.0-1+0")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-4+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-4+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.3-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.3.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.3.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.4.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.4.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "3.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "3.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "3.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "4.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "4.0.0-1+0")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.3-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.3.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.3.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.4.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.4.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "3.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "3.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "3.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "4.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "4.0.0-foo.1+0")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.3-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.3.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.3.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.4.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.4.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "3.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "3.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "3.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "4.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "4.0.0-bar.1+0")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.3-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.3.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.3.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.4.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.4.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "3.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "3.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "3.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "4.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "4.0.0-foo.1+0")] + public string GetVersionWithLabelNullAndPreventIncrementOfMergedBranchVersionFalseOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null).WithPreventIncrementOfMergedBranchVersion(false)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-4+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-4+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.2-3+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-3+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.2-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.4.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.4.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-3+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.2-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.2.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "4.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "4.0.0-1+0")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-4+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-4+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-3+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-3+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.2-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.4.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.4.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-3+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.2-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.2.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "4.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "4.0.0-1+0")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.2-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.4.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.4.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "4.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "4.0.0-foo.1+0")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.2-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.4.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.4.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "4.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "4.0.0-bar.1+0")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.2-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.4.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.4.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "4.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "4.0.0-foo.1+0")] + public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-4+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-4+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.3-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.3.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.3.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.4.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.4.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "3.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "3.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "3.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "4.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "4.0.0-1+0")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-4+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-4+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.3-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.3.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.3.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.4.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.4.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "3.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "3.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "3.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "4.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "4.0.0-1+0")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.3.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.4.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.4.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "3.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "3.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "4.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "4.0.0-foo.1+0")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.3.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.4.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.4.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "3.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "3.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "4.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "4.0.0-bar.1+0")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.3.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.4.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.4.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "3.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "3.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "4.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "4.0.0-foo.1+0")] + public string GetVersionWithEmptyLabelAndPreventIncrementOfMergedBranchVersionFalseOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty).WithPreventIncrementOfMergedBranchVersion(false)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.4+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.4+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.2-foo.3+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-foo.3+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.2-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.4.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.4.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-foo.3+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "4.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "4.0.0-foo.1+0")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.2-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.4.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.4.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.2-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.2.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "4.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "4.0.0-1+0")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.4+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.4+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.3+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.3+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.2-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.4.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.4.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.3+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "4.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "4.0.0-foo.1+0")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.2-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.4.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.4.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "4.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "4.0.0-bar.1+0")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.4+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.4+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.3+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.3+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.2-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.4.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.4.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.3+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "4.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "4.0.0-foo.1+0")] + public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.4+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.4+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.3-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.3.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.3.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.4.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.4.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "3.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "3.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "3.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "4.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "4.0.0-foo.1+0")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.3.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.4.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.4.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "3.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "3.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "4.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "4.0.0-1+0")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.4+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.4+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.3-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.3.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.3.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.4.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.4.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "3.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "3.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "3.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "4.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "4.0.0-foo.1+0")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.3.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.4.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.4.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "3.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "3.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "4.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "4.0.0-bar.1+0")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.4+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.4+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.3-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.3.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.3.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.4.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.4.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "3.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "3.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "3.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "4.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "4.0.0-foo.1+0")] + public string GetVersionWithLabelFooAndPreventIncrementOfMergedBranchVersionFalseOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo").WithPreventIncrementOfMergedBranchVersion(false)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.4+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.4+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.2-bar.3+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-bar.3+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.2-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.4.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.4.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-bar.3+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "4.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "4.0.0-bar.1+0")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.2-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.4.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.4.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.2-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.2.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "4.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "4.0.0-1+0")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.2-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.4.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.4.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "4.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "4.0.0-foo.1+0")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.4+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.4+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.3+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.3+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.2-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.4.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.4.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.3+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "4.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "4.0.0-bar.1+0")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.2-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.4.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.4.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "4.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "4.0.0-foo.1+0")] + public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.4+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.4+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.3-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.3.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.3.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.4.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.4.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "3.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "3.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "3.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "4.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "4.0.0-bar.1+0")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.3.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.4.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.4.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "3.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "3.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "4.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "4.0.0-1+0")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.3.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.4.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.4.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "3.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "3.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "4.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "4.0.0-foo.1+0")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.4+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.4+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.3-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.3.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.3.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.4.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.4.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "3.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "3.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "3.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "4.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "4.0.0-bar.1+0")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.3.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.4.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.4.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "3.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "3.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "4.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "4.0.0-foo.1+0")] + public string GetVersionWithLabelBarAndPreventIncrementOfMergedBranchVersionFalseOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar").WithPreventIncrementOfMergedBranchVersion(false)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhen.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhen.cs new file mode 100644 index 0000000000..d1b5c57edc --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhen.cs @@ -0,0 +1,60 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAFeatureBranchWithOneCommitWhen + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // A 59 minutes ago (HEAD -> feature/foo) + + fixture = new EmptyRepositoryFixture("feature/foo"); + + fixture.MakeACommit("A"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [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.1+1")] + [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 GetVersion(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitHasBumpMessageMajor.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitHasBumpMessageMajor.cs new file mode 100644 index 0000000000..c6ba38b315 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitHasBumpMessageMajor.cs @@ -0,0 +1,118 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAFeatureBranchWithOneCommitWhenCommitHasBumpMessageMajor + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // A 59 minutes ago (HEAD -> feature/foo) + + fixture = new EmptyRepositoryFixture("feature/foo"); + + fixture.MakeACommit("A +semver: major"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + public string GetVersion(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [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.1+1")] + [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 GetVersionWithDisabledMessageIncrementing(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [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.1+1")] + [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 GetVersionWithMergeMessageOnlyIncrementing(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitHasBumpMessageMinor.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitHasBumpMessageMinor.cs new file mode 100644 index 0000000000..aad3baade1 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitHasBumpMessageMinor.cs @@ -0,0 +1,118 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAFeatureBranchWithOneCommitWhenCommitHasBumpMessageMinor + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // A 59 minutes ago (HEAD -> feature/foo) + + fixture = new EmptyRepositoryFixture("feature/foo"); + + fixture.MakeACommit("A +semver: minor"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [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.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.0-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 GetVersion(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [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.1+1")] + [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 GetVersionWithDisabledMessageIncrementing(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [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.1+1")] + [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 GetVersionWithMergeMessageOnlyIncrementing(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitHasBumpMessagePatch.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitHasBumpMessagePatch.cs new file mode 100644 index 0000000000..79badbe5df --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitHasBumpMessagePatch.cs @@ -0,0 +1,118 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAFeatureBranchWithOneCommitWhenCommitHasBumpMessagePatch + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // A 59 minutes ago (HEAD -> feature/foo) + + fixture = new EmptyRepositoryFixture("feature/foo"); + + fixture.MakeACommit("A +semver: patch"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [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.1-bar.1+1")] + [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 GetVersion(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [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.1+1")] + [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 GetVersionWithDisabledMessageIncrementing(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [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.1+1")] + [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 GetVersionWithMergeMessageOnlyIncrementing(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitTaggedAsPreRelease.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitTaggedAsPreRelease.cs new file mode 100644 index 0000000000..ba140ea4e1 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitTaggedAsPreRelease.cs @@ -0,0 +1,91 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAFeatureBranchWithOneCommitWhenCommitTaggedAsPreRelease + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // A 59 minutes ago (HEAD -> feature/foo) (tag 0.0.0-4) + + fixture = new EmptyRepositoryFixture("feature/foo"); + + fixture.MakeACommit("A"); + fixture.ApplyTag("0.0.0-4"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "0.0.0-4")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "0.0.0-4")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [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.1+1")] + [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 GetVersion(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + 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")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "0.0.0-5+0")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+0")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-5+0")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-5+0")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "0.0.0-5+0")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [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.1+1")] + [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) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitTaggedAsPreReleaseBar.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitTaggedAsPreReleaseBar.cs new file mode 100644 index 0000000000..8793e188e8 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitTaggedAsPreReleaseBar.cs @@ -0,0 +1,91 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAFeatureBranchWithOneCommitWhenCommitTaggedAsPreReleaseBar + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // A 59 minutes ago (HEAD -> feature/foo) (tag 0.0.0-bar) + + fixture = new EmptyRepositoryFixture("feature/foo"); + + fixture.MakeACommit("A"); + fixture.ApplyTag("0.0.0-bar"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [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, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [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 GetVersion(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + 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, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [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) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitTaggedAsPreReleaseFoo.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitTaggedAsPreReleaseFoo.cs new file mode 100644 index 0000000000..926d94fd3c --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitTaggedAsPreReleaseFoo.cs @@ -0,0 +1,91 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAFeatureBranchWithOneCommitWhenCommitTaggedAsPreReleaseFoo + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // A 59 minutes ago (HEAD -> feature/foo) (tag 0.0.0-foo.4) + + fixture = new EmptyRepositoryFixture("feature/foo"); + + fixture.MakeACommit("A"); + fixture.ApplyTag("0.0.0-foo.4"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.4")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.4")] + + [TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [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 GetVersion(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + 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")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.5+0")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+0")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.5+0")] + [TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.5+0")] + [TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.5+0")] + + [TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [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) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitTaggedAsStable.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitTaggedAsStable.cs new file mode 100644 index 0000000000..40fe52b045 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithOneCommitWhenCommitTaggedAsStable.cs @@ -0,0 +1,91 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAFeatureBranchWithOneCommitWhenCommitTaggedAsStable + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // A 59 minutes ago (HEAD -> feature/foo) (tag 0.0.0) + + fixture = new EmptyRepositoryFixture("feature/foo"); + + fixture.MakeACommit("A"); + fixture.ApplyTag("0.0.0"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "0.0.0")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "0.0.0")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0")] + + [TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0")] + public string GetVersion(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + 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")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+0")] + + [TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [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) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithThreeCommitsBranchedFromMainWhen.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithThreeCommitsBranchedFromMainWhen.cs new file mode 100644 index 0000000000..7dfdc6fbf3 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithThreeCommitsBranchedFromMainWhen.cs @@ -0,0 +1,319 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAFeatureBranchWithThreeCommitsBranchedFromMainWhen + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // D 45 minutes ago (HEAD -> feature/foo) + // C 46 minutes ago + // B 47 minutes ago + // A 51 minutes ago (main) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.BranchTo("feature/foo"); + fixture.MakeACommit("B"); + fixture.MakeACommit("C"); + fixture.MakeACommit("D"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+3")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+3")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+3")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+3")] + public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+3")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+3")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+3")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+3")] + public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+3")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-foo.2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+3")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-foo.2+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+3")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-foo.2+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+3")] + public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithThreeCommitsMergedToMainWhen.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithThreeCommitsMergedToMainWhen.cs new file mode 100644 index 0000000000..1c40e79eb5 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithThreeCommitsMergedToMainWhen.cs @@ -0,0 +1,960 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAFeatureBranchWithThreeCommitsMergedToMainWhen + { + private EmptyRepositoryFixture? fixture; + + private static GitFlowConfigurationBuilder TrunkBasedBuilder => GitFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // * 54 minutes ago (HEAD -> main) + // |\ + // | D 55 minutes ago (feature/foo) + // | C 56 minutes ago + // | B 57 minutes ago + // |/ + // A 58 minutes ago + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.BranchTo("feature/foo"); + fixture.MakeACommit("B"); + fixture.MakeACommit("C"); + fixture.MakeACommit("D"); + fixture.MergeTo("main"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+4")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+4")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+4")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+4")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+4")] + public string GetVersionWithLabelNullOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.2-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.0.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+4")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.0.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+4")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+4")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.0-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+4")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+4")] + public string GetVersionWithLabelNullAndPreventIncrementOfMergedBranchVersionFalseOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null).WithPreventIncrementOfMergedBranchVersion(false)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+4")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+4")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-2+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-2+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-2+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-1+4")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-2+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-2+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-2+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-1+4")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-2+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-2+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-2+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-1+4")] + public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.2-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.0.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+4")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.0.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+4")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-2+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.0.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-1+4")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-2+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.0.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-1+4")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-2+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.0.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-1+4")] + public string GetVersionWithEmptyLabelAndPreventIncrementOfMergedBranchVersionFalseOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty).WithPreventIncrementOfMergedBranchVersion(false)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.2+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-foo.2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-foo.2+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-foo.2+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+4")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-foo.2+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-foo.2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-foo.2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-foo.2+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-foo.2+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-foo.1+4")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+4")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-foo.2+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-foo.2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-foo.2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-foo.2+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-foo.2+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-foo.1+4")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.2+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+4")] + public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.2+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.2-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+4")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-foo.2+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-foo.2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-foo.1+4")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+4")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-foo.2+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-foo.2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-foo.1+4")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.2+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+4")] + public string GetVersionWithLabelFooAndPreventIncrementOfMergedBranchVersionFalseOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo").WithPreventIncrementOfMergedBranchVersion(false)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.2+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-bar.2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-bar.2+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-bar.2+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+4")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-bar.2+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-bar.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-bar.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-bar.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-bar.2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-bar.2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-bar.2+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-bar.2+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-bar.1+4")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-bar.2+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-bar.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-bar.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-bar.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-bar.2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-bar.2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-bar.2+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-bar.2+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-bar.1+4")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.2+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.2+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+4")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-bar.2+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-bar.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-bar.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-bar.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-bar.2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-bar.2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-bar.2+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-bar.2+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-bar.1+4")] + public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.2+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.2-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.0-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+4")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-bar.2+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-bar.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-bar.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-bar.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-bar.2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.0-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-bar.1+4")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-bar.2+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-bar.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-bar.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-bar.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-bar.2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.0-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-bar.1+4")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.0-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+4")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-bar.2+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-bar.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-bar.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-bar.1+4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-bar.2+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.0-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-bar.1+4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-bar.1+4")] + public string GetVersionWithLabelBarAndPreventIncrementOfMergedBranchVersionFalseOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar").WithPreventIncrementOfMergedBranchVersion(false)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithThreeCommitsWhen.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithThreeCommitsWhen.cs new file mode 100644 index 0000000000..27ba0c4a96 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithThreeCommitsWhen.cs @@ -0,0 +1,64 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAFeatureBranchWithThreeCommitsWhen + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // C 57 minutes ago (HEAD -> feature/foo) + // B 58 minutes ago + // A 59 minutes ago + + fixture = new EmptyRepositoryFixture("feature/foo"); + + fixture.MakeACommit("A"); + fixture.MakeACommit("B"); + fixture.MakeACommit("C"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+3")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+3")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+3")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+3")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+3")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+3")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+3")] + [TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+3")] + + [TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+3")] + [TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+3")] + public string GetVersion(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithTwoCommitsBranchedFromMainWhen.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithTwoCommitsBranchedFromMainWhen.cs new file mode 100644 index 0000000000..d6c7d20ee6 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithTwoCommitsBranchedFromMainWhen.cs @@ -0,0 +1,317 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAFeatureBranchWithTwoCommitsBranchedFromMainWhen + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // C 46 minutes ago (HEAD -> feature/foo) + // B 47 minutes ago + // A 51 minutes ago (main) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.BranchTo("feature/foo"); + fixture.MakeACommit("B"); + fixture.MakeACommit("C"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.2+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-foo.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.2+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-foo.2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+2")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+2")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-foo.2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+2")] + public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithTwoCommitsMergedToMainWhen.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithTwoCommitsMergedToMainWhen.cs new file mode 100644 index 0000000000..0a5b103691 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithTwoCommitsMergedToMainWhen.cs @@ -0,0 +1,958 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAFeatureBranchWithTwoCommitsMergedToMainWhen + { + private EmptyRepositoryFixture? fixture; + + private static GitFlowConfigurationBuilder TrunkBasedBuilder => GitFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // * 54 minutes ago (HEAD -> main) + // |\ + // | C 55 minutes ago (feature/foo) + // | B 56 minutes ago + // |/ + // A 58 minutes ago + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.BranchTo("feature/foo"); + fixture.MakeACommit("B"); + fixture.MakeACommit("C"); + fixture.MergeTo("main"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+3")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+3")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+3")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+3")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+3")] + public string GetVersionWithLabelNullOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.2-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+3")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+3")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+3")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+3")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+3")] + public string GetVersionWithLabelNullAndPreventIncrementOfMergedBranchVersionFalseOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null).WithPreventIncrementOfMergedBranchVersion(false)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+3")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+3")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-2+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-2+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-1+3")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-2+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-2+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-1+3")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-2+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-2+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-1+3")] + public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.2-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+3")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+3")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-1+3")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-1+3")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-1+3")] + public string GetVersionWithEmptyLabelAndPreventIncrementOfMergedBranchVersionFalseOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty).WithPreventIncrementOfMergedBranchVersion(false)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-foo.2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-foo.2+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-foo.2+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+3")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-foo.2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-foo.2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-foo.2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-foo.2+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-foo.2+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-foo.1+3")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+3")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-foo.2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-foo.2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-foo.2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-foo.2+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-foo.2+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-foo.1+3")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+3")] + public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+3")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-foo.2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-foo.2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-foo.1+3")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-foo.1+3")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-foo.2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-foo.2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-foo.1+3")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-foo.1+3")] + public string GetVersionWithLabelFooAndPreventIncrementOfMergedBranchVersionFalseOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo").WithPreventIncrementOfMergedBranchVersion(false)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-bar.2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-bar.2+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-bar.2+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+3")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-bar.2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-bar.2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-bar.2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-bar.2+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-bar.2+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-bar.1+3")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-bar.2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-bar.2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-bar.2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-bar.2+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-bar.2+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-bar.1+3")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.2+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.2+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+3")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-bar.2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-bar.2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-bar.2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-bar.2+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-bar.2+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-bar.1+3")] + public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.2-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+3")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-bar.2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-bar.2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-bar.1+3")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-bar.2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-bar.2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.2-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.2.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "2.0.0-bar.1+3")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+3")] + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-bar.2+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-bar.2+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.2-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.2.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-bar.1+3")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "2.0.0-bar.1+3")] + public string GetVersionWithLabelBarAndPreventIncrementOfMergedBranchVersionFalseOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar").WithPreventIncrementOfMergedBranchVersion(false)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithTwoCommitsWhenFirstCommitTaggedAsPreRelease.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithTwoCommitsWhenFirstCommitTaggedAsPreRelease.cs new file mode 100644 index 0000000000..5ca91c660d --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithTwoCommitsWhenFirstCommitTaggedAsPreRelease.cs @@ -0,0 +1,63 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAFeatureBranchWithTwoCommitsWhenFirstCommitTaggedAsPreRelease + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 58 minutes ago (HEAD -> feature/foo) + // A 59 minutes ago (tag 0.0.3-4) + + fixture = new EmptyRepositoryFixture("feature/foo"); + + fixture.MakeACommit("A"); + fixture.ApplyTag("0.0.3-4"); + fixture.MakeACommit("B"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.3-5+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-5+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.0.3-5+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "0.0.3-5+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.3-5+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-5+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.0.3-5+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "0.0.3-5+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.3-foo.1+2")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+2")] + [TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + + [TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.0.3-bar.1+2")] + [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+2")] + [TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + public string GetVersion(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithTwoCommitsWhenFirstCommitTaggedAsPreReleaseBar.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithTwoCommitsWhenFirstCommitTaggedAsPreReleaseBar.cs new file mode 100644 index 0000000000..9712a5cc7e --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithTwoCommitsWhenFirstCommitTaggedAsPreReleaseBar.cs @@ -0,0 +1,63 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAFeatureBranchWithTwoCommitsWhenFirstCommitTaggedAsPreReleaseBar + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 58 minutes ago (HEAD -> feature/foo) + // A 59 minutes ago (tag 0.0.3-bar) + + fixture = new EmptyRepositoryFixture("feature/foo"); + + fixture.MakeACommit("A"); + fixture.ApplyTag("0.0.3-bar"); + fixture.MakeACommit("B"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.3-bar+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-bar+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.0.3-bar+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "0.0.3-bar+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.3-1+2")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+2")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.3-foo.1+2")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+2")] + [TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+2")] + [TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+2")] + + [TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.0.3-bar+1")] + [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar+1")] + [TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.3-bar+1")] + [TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "0.0.3-bar+1")] + public string GetVersion(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithTwoCommitsWhenFirstCommitTaggedAsPreReleaseFoo.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithTwoCommitsWhenFirstCommitTaggedAsPreReleaseFoo.cs new file mode 100644 index 0000000000..8001fbe161 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAFeatureBranchWithTwoCommitsWhenFirstCommitTaggedAsPreReleaseFoo.cs @@ -0,0 +1,63 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAFeatureBranchWithTwoCommitsWhenFirstCommitTaggedAsPreReleaseFoo + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 58 minutes ago (HEAD -> feature/foo) + // A 59 minutes ago (tag 0.0.3-foo.4) + + fixture = new EmptyRepositoryFixture("feature/foo"); + + fixture.MakeACommit("A"); + fixture.ApplyTag("0.0.3-foo.4"); + fixture.MakeACommit("B"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.3-foo.5+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-foo.5+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.0.3-foo.5+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "0.0.3-foo.5+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.3-1+2")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+2")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+2")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+2")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.3-foo.5+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.5+1")] + [TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.3-foo.5+1")] + [TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "0.0.3-foo.5+1")] + + [TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.0.3-bar.1+2")] + [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+2")] + [TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+2")] + [TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+2")] + public string GetVersion(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhen.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhen.cs new file mode 100644 index 0000000000..a3e593d0c4 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhen.cs @@ -0,0 +1,487 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAMainBranchWithOneCommitBranchedToFeatureWhen + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // A 58 minutes ago (HEAD -> feature/foo, main) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.BranchTo("feature/foo"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.2+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.2+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.2+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.2+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.1-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.1.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitHasBumpMessageMajor.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitHasBumpMessageMajor.cs new file mode 100644 index 0000000000..946b8dac40 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitHasBumpMessageMajor.cs @@ -0,0 +1,1407 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitHasBumpMessageMajor + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // A 58 minutes ago (HEAD -> feature/foo, main) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A +semver: major"); + fixture.BranchTo("feature/foo"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.1.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithNoLabelAndDisabledMessageIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithNoLabelAndMergeMessageOnlyIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.1.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithEmptyLabelAndDisabledMessageIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithEmptyLabelAndMergeMessageOnlyIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.2+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.1.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.2+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.2+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithLabelFooAndDisabledMergeMessageIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo") + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.2+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.2+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithLabelFooAndMergeMessageOnlyIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo") + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "1.0.0-bar.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-bar.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "1.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "1.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.1.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.2+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.2+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.1-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.1.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithLabelBarAndDisabledMergeMessageIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar") + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.2+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.2+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.1-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.1.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithLabelBarAndMergeMessageOnlyIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar") + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitHasBumpMessageMinor.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitHasBumpMessageMinor.cs new file mode 100644 index 0000000000..8ab792eeac --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitHasBumpMessageMinor.cs @@ -0,0 +1,1407 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitHasBumpMessageMinor + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // A 58 minutes ago (HEAD -> feature/foo, main) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A +semver: minor"); + fixture.BranchTo("feature/foo"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.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.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.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.1.0-foo.1+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.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.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithNoLabelAndDisabledMessageIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithNoLabelAndMergeMessageOnlyIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.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.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.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.1.0-foo.1+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.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.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithEmptyLabelAndDisabledMessageIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithEmptyLabelAndMergeMessageOnlyIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.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.1.0-foo.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.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.1.0-foo.2+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.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.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.2+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.2+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithLabelFooAndDisabledMergeMessageIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo") + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.2+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.2+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithLabelFooAndMergeMessageOnlyIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo") + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.1.0-bar.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-bar.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.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.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-bar.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.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.1.0-foo.1+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.1.0-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.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.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.2+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.2+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.1-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.1.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithLabelBarAndDisabledMergeMessageIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar") + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.2+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.2+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.1-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.1.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithLabelBarAndMergeMessageOnlyIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar") + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitHasBumpMessagePatch.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitHasBumpMessagePatch.cs new file mode 100644 index 0000000000..55d9ed6277 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitHasBumpMessagePatch.cs @@ -0,0 +1,1406 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitHasBumpMessagePatch + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // A 58 minutes ago (HEAD -> feature/foo, main) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A +semver: patch"); + fixture.BranchTo("feature/foo"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.1-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-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.1-foo.1+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithNoLabelAndDisabledMessageIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithNoLabelAndMergeMessageOnlyIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.1-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-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.1-foo.1+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithEmptyLabelAndDisabledMessageIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithEmptyLabelAndMergeMessageOnlyIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.1-foo.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-foo.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-foo.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-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.1-foo.2+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.2+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.2+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithLabelFooAndDisabledMergeMessageIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo") + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.2+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.2+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithLabelFooAndMergeMessageOnlyIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo") + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.1-bar.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-bar.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.1-bar.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-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.1-foo.1+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.1.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.2+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.2+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.1-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.1.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithLabelBarAndDisabledMergeMessageIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar") + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.2+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.2+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.1-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.1.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithLabelBarAndMergeMessageOnlyIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar") + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitTaggedAsPreRelease.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitTaggedAsPreRelease.cs new file mode 100644 index 0000000000..245601d6c6 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitTaggedAsPreRelease.cs @@ -0,0 +1,951 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitTaggedAsPreRelease + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // A 58 minutes ago (HEAD -> feature/foo, main) (tag 0.0.0-4) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.ApplyTag("0.0.0-4"); + fixture.BranchTo("feature/foo"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + 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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-5+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-5+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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-5+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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-5+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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-5+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label) + //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + 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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-5+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-5+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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-5+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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-5+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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-5+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label) + //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.2+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + 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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-5+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.2+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label) + //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.2+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.1-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.1.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + 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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-5+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.2+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.1-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.1.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0-5+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label) + //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) + ).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 new file mode 100644 index 0000000000..f75c14ca09 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitTaggedAsPreReleaseBar.cs @@ -0,0 +1,951 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitTaggedAsPreReleaseBar + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // A 58 minutes ago (HEAD -> feature/foo, main) (tag 0.0.0-bar) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.ApplyTag("0.0.0-bar"); + fixture.BranchTo("feature/foo"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar")] + [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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.Patch, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar")] + [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.Patch, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.Patch, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.Patch, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.Patch, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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.Patch, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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.Patch, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + 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.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.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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.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.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.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")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-bar+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.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")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.1-bar+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.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")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-bar+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.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")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-bar+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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.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")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-bar+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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.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")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label) + //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.Patch, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar")] + [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.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.Patch, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.Patch, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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.Patch, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + 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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.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.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.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.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")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.1-bar+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.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")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-bar+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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.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")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label) + //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.2+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.Patch, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar")] + [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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.2+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.Patch, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.Patch, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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.Patch, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + 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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.2+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.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.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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.2+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.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")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.1-bar+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.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")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-bar+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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.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")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label) + //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar")] + [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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.Patch, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar")] + [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.Patch, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.Patch, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.Patch, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.Patch, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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.Patch, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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.Patch, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + 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.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.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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.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.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.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")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-bar+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.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")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.1-bar+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [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.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")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-bar+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.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")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-bar+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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.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")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-bar+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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.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")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label) + //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) + ).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 new file mode 100644 index 0000000000..03e6ad2538 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitTaggedAsPreReleaseFoo.cs @@ -0,0 +1,951 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitTaggedAsPreReleaseFoo + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // A 58 minutes ago (HEAD -> feature/foo, main) (tag 0.0.0-foo.4) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.ApplyTag("0.0.0-foo.4"); + fixture.BranchTo("feature/foo"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.4")] + [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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + 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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.5+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.5+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+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.5+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.5+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.5+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.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.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.5+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+0")] + [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")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + public string GetVersionWithNoLabelOnMainAndTakeAlwaysIncrementedVersionOnFeature( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label) + //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + 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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-2+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.5+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+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.5+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.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.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+0")] + [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")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + public string GetVersionWithEmptyLabelOnMainAndTakeAlwaysIncrementedVersionOnFeature( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label) + //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.4")] + [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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + 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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.5+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.5+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+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.5+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.5+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.5+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.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.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.5+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+0")] + [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")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + public string GetVersionWithLabelFooOnMainAndTakeAlwaysIncrementedVersionOnFeature( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label) + //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.2+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0-foo.4")] + public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + 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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.2+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.5+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+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.5+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.1-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.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.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.5+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.5+0")] + [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")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + public string GetVersionWithLabelBarOnMainAndTakeAlwaysIncrementedVersionOnFeature( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label) + //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) + ).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 new file mode 100644 index 0000000000..5de07cfe51 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitTaggedAsStable.cs @@ -0,0 +1,951 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAMainBranchWithOneCommitBranchedToFeatureWhenCommitTaggedAsStable + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // A 58 minutes ago (HEAD -> feature/foo, main) (tag 0.0.0) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.ApplyTag("0.0.0"); + fixture.BranchTo("feature/foo"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0")] + public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + 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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-1+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.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.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+0")] + [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")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + public string GetVersionWithNoLabelOnMainAndTakeAlwaysIncrementedVersionOnFeature( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label) + //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0")] + public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + 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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-1+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.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.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+0")] + [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")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + public string GetVersionWithEmptyLabelOnMainAndTakeAlwaysIncrementedVersionOnFeature( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label) + //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0")] + public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + 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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.1+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.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.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+0")] + [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")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + public string GetVersionWithLabelFooOnMainAndTakeAlwaysIncrementedVersionOnFeature( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label) + //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.0")] + public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + 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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.1+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.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.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.1+0")] + [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")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + public string GetVersionWithLabelBarOnMainAndTakeAlwaysIncrementedVersionOnFeature( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label) + //.WithTakeIncrementedVersion(TakeIncrementedVersion.TakeAlwaysIncrementedVersion) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitWhen.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitWhen.cs new file mode 100644 index 0000000000..3e6257947a --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitWhen.cs @@ -0,0 +1,60 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAMainBranchWithOneCommitWhen + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // A 59 minutes ago (HEAD -> main) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [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.1+1")] + [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 GetVersion(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitWhenCommitHasBumpMessageMajor.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitWhenCommitHasBumpMessageMajor.cs new file mode 100644 index 0000000000..50ac4c58cb --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitWhenCommitHasBumpMessageMajor.cs @@ -0,0 +1,118 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAMainBranchWithOneCommitWhenCommitHasBumpMessageMajor + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // A 59 minutes ago (HEAD -> main) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A +semver: major"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "1.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+1")] + public string GetVersion(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [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.1+1")] + [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 GetVersionWithDisabledMessageIncrementing(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [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.1+1")] + [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 GetVersionWithMergeMessageOnlyIncrementing(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitWhenCommitHasBumpMessageMinor.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitWhenCommitHasBumpMessageMinor.cs new file mode 100644 index 0000000000..b0b578915a --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitWhenCommitHasBumpMessageMinor.cs @@ -0,0 +1,118 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAMainBranchWithOneCommitWhenCommitHasBumpMessageMinor + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // A 59 minutes ago (HEAD -> main) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A +semver: minor"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [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.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.0-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 GetVersion(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [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.1+1")] + [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 GetVersionWithDisabledMessageIncrementing(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [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.1+1")] + [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 GetVersionWithMergeMessageOnlyIncrementing(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitWhenCommitHasBumpMessagePatch.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitWhenCommitHasBumpMessagePatch.cs new file mode 100644 index 0000000000..57b2b50ed5 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitWhenCommitHasBumpMessagePatch.cs @@ -0,0 +1,118 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAMainBranchWithOneCommitWhenCommitHasBumpMessagePatch + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // A 59 minutes ago (HEAD -> main) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A +semver: patch"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [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.1-bar.1+1")] + [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 GetVersion(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [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.1+1")] + [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 GetVersionWithDisabledMessageIncrementing(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [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.1+1")] + [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 GetVersionWithMergeMessageOnlyIncrementing(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitWhenCommitTaggedAsPreRelease.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitWhenCommitTaggedAsPreRelease.cs new file mode 100644 index 0000000000..872a2b1c2f --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitWhenCommitTaggedAsPreRelease.cs @@ -0,0 +1,61 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAMainBranchWithOneCommitWhenCommitTaggedAsPreRelease + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // A 59 minutes ago (HEAD -> main) (tag 0.0.0-4) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.ApplyTag("0.0.0-4"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "0.0.0-4")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.0.0-4")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "0.0.0-4")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [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.1+1")] + [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 GetVersion(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitWhenCommitTaggedAsPreReleaseBar.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitWhenCommitTaggedAsPreReleaseBar.cs new file mode 100644 index 0000000000..455b312395 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitWhenCommitTaggedAsPreReleaseBar.cs @@ -0,0 +1,61 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAMainBranchWithOneCommitWhenCommitTaggedAsPreReleaseBar + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // A 59 minutes ago (HEAD -> main) (tag 0.0.0-bar) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.ApplyTag("0.0.0-bar"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [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, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [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 GetVersion(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitWhenCommitTaggedAsPreReleaseFoo.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitWhenCommitTaggedAsPreReleaseFoo.cs new file mode 100644 index 0000000000..6b0afcb49d --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitWhenCommitTaggedAsPreReleaseFoo.cs @@ -0,0 +1,61 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAMainBranchWithOneCommitWhenCommitTaggedAsPreReleaseFoo + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // A 59 minutes ago (HEAD -> main) (tag 0.0.0-foo.4) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.ApplyTag("0.0.0-foo.4"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "0.0.0-foo.4")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0-foo.4")] + [TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0-foo.4")] + + [TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+1")] + [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 GetVersion(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitWhenCommitTaggedAsStable.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitWhenCommitTaggedAsStable.cs new file mode 100644 index 0000000000..afa59167e9 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithOneCommitWhenCommitTaggedAsStable.cs @@ -0,0 +1,61 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAMainBranchWithOneCommitWhenCommitTaggedAsStable + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // A 59 minutes ago (HEAD -> main) (tag 0.0.0) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.ApplyTag("0.0.0"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "0.0.0")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "0.0.0")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "0.0.0")] + + [TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.0.0")] + [TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "0.0.0")] + public string GetVersion(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithThreeCommitsWhen.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithThreeCommitsWhen.cs new file mode 100644 index 0000000000..44940742ec --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithThreeCommitsWhen.cs @@ -0,0 +1,64 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAMainBranchWithThreeCommitsWhen + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // C 57 minutes agov (HEAD -> main) + // B 58 minutes ago + // A 59 minutes ago + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.MakeACommit("B"); + fixture.MakeACommit("C"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-3+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "3.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-3+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.3+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+1")] + [TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.3+1")] + [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+1")] + [TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+1")] + public string GetVersion(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsBranchedToFeatureWhen.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsBranchedToFeatureWhen.cs new file mode 100644 index 0000000000..86473801b3 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsBranchedToFeatureWhen.cs @@ -0,0 +1,488 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAMainBranchWithTwoCommitsBranchedToFeatureWhen + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 54 minutes ago (main) (HEAD -> feature/foo) + // A 56 minutes ago + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.MakeACommit("B"); + fixture.BranchTo("feature/foo"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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.2-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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.2-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.3+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.3+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.2-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.3+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.2-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsBranchedToFeatureWhenFirstCommitHasBumpMessageMajor.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsBranchedToFeatureWhenFirstCommitHasBumpMessageMajor.cs new file mode 100644 index 0000000000..2563b590e5 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsBranchedToFeatureWhenFirstCommitHasBumpMessageMajor.cs @@ -0,0 +1,1409 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAMainBranchWithTwoCommitsBranchedToFeatureWhenFirstCommitHasBumpMessageMajor + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 54 minutes ago (main) (HEAD -> feature/foo) + // A 56 minutes ago + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A +semver: major"); + fixture.MakeACommit("B"); + fixture.BranchTo("feature/foo"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "1.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "1.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "1.0.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "1.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "1.0.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "1.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.2-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "1.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "1.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "1.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "1.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "1.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "1.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "1.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "1.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "1.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "1.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "1.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "1.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.2.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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.2-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithNoLabelAndDisabledMessageIncrementingOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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.2-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithNoLabelAndMergeMessageOnlyIncrementingOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "1.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "1.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "1.0.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "1.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "1.0.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "1.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.2-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "1.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "1.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "1.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "1.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "1.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "1.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "1.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "1.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "1.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "1.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "1.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "1.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.2.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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.2-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + + public string GetVersionWithEmptyLabelAndDisabledMessageIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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.2-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + + public string GetVersionWithEmptyLabelAndMergeMessageOnlyIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "1.0.0-foo.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-foo.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.3+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "1.0.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "1.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "1.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "1.0.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.2-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "1.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "1.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "1.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "1.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "1.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "1.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "1.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "1.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "1.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "1.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "1.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "1.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.2.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.3+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.3+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.2-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithLabelFooAndDisabledMessageIncrementModeOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo") + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.3+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.3+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.2-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithLabelFooAndMergeMessageOnlyIncrementModeOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo") + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "1.0.0-bar.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.0-bar.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.0-bar.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "1.0.1-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "1.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "1.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "1.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "1.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "1.0.1-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.0.2-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "1.1.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "1.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "1.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "1.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "1.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "1.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "1.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "1.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "1.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "foo", ExpectedResult = "1.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "1.1.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "1.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "1.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "1.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "1.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "1.2.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.3+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.2-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithLabelBarAndDisabledMessageIncrementModeOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar") + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.3+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.2-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithLabelBarAndMergeMessageOnlyIncrementModeOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar") + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsBranchedToFeatureWhenFirstCommitHasBumpMessageMinor.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsBranchedToFeatureWhenFirstCommitHasBumpMessageMinor.cs new file mode 100644 index 0000000000..69ad50d9e4 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsBranchedToFeatureWhenFirstCommitHasBumpMessageMinor.cs @@ -0,0 +1,1409 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAMainBranchWithTwoCommitsBranchedToFeatureWhenFirstCommitHasBumpMessageMinor + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 54 minutes ago (main) (HEAD -> feature/foo) + // A 56 minutes ago + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A +semver: minor"); + fixture.MakeACommit("B"); + fixture.BranchTo("feature/foo"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.1.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.1.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.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.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.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.1.0-foo.1+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.1.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.1.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.1.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.1.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.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.1.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.2-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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.2-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithNoLabelAndDisabledMessageIncrementingOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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.2-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithNoLabelAndMergeMessageOnlyIncrementingOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.1.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.1.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.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.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.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.1.0-foo.1+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.1.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.1.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.1.1-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.1.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.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.1.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.2-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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.2-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + + public string GetVersionWithEmptyLabelAndDisabledMessageIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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.2-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + + public string GetVersionWithEmptyLabelAndMergeMessageOnlyIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.1.0-foo.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-foo.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.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.1.0-foo.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.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.1.0-foo.3+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.1.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.1.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.1.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.1.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.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.1.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.1-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.2-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.3+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.3+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.2-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithLabelFooAndDisabledMessageIncrementModeOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo") + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.3+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.3+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.2-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithLabelFooAndMergeMessageOnlyIncrementModeOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo") + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.1.0-bar.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.0-bar.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.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.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.0-bar.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.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.1.0-foo.1+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.1.1-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.1.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.1.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.1.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.1.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.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.1.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.1.1-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.1.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.1.2-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.3+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.2-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithLabelBarAndDisabledMessageIncrementModeOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar") + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.3+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.2-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithLabelBarAndMergeMessageOnlyIncrementModeOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar") + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsBranchedToFeatureWhenFirstCommitHasBumpMessagePatch.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsBranchedToFeatureWhenFirstCommitHasBumpMessagePatch.cs new file mode 100644 index 0000000000..bc7f3738f2 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsBranchedToFeatureWhenFirstCommitHasBumpMessagePatch.cs @@ -0,0 +1,1409 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAMainBranchWithTwoCommitsBranchedToFeatureWhenFirstCommitHasBumpMessagePatch + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 54 minutes ago (main) (HEAD -> feature/foo) + // A 56 minutes ago + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A +semver: patch"); + fixture.MakeACommit("B"); + fixture.BranchTo("feature/foo"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.1-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.1-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.1-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-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.1-foo.1+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.2-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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.2-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithNoLabelAndDisabledMessageIncrementingOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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.2-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithNoLabelAndMergeMessageOnlyIncrementingOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.1-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.1-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.1-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-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.1-foo.1+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.2-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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.2-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + + public string GetVersionWithEmptyLabelAndDisabledMessageIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+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.2-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + + public string GetVersionWithEmptyLabelAndMergeMessageOnlyIncrementingOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.1-foo.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-foo.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-foo.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-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.1-foo.3+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.2-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.3+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.3+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.2-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithLabelFooAndDisabledMessageIncrementModeOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo") + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-foo.3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-foo.3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.0-foo.3+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.3+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.2-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithLabelFooAndMergeMessageOnlyIncrementModeOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo") + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.1-bar.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.1-bar.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.1-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [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.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.1-bar.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.1-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.2-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.1-foo.1+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.2-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.3+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.2-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithLabelBarAndDisabledMessageIncrementModeOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar") + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.0-bar.3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.0-bar.3+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")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.1-foo.1+0")] + [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.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.1-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.0-bar.3+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.2-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.2-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.2-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.2-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithLabelBarAndMergeMessageOnlyIncrementModeOnMain( + IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar") + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsBranchedToFeatureWhenFirstCommitTaggedAsPreRelease.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsBranchedToFeatureWhenFirstCommitTaggedAsPreRelease.cs new file mode 100644 index 0000000000..e2abafa7a3 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsBranchedToFeatureWhenFirstCommitTaggedAsPreRelease.cs @@ -0,0 +1,489 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAMainBranchWithTwoCommitsBranchedToFeatureWhenFirstCommitTaggedAsPreRelease + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 54 minutes ago (main) (HEAD -> feature/foo) + // A 56 minutes ago (0.0.3-4) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.ApplyTag("0.0.3-4"); + fixture.MakeACommit("B"); + fixture.BranchTo("feature/foo"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.3-6+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-6+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.3-6+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-6+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.4-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.3-foo.1+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.4-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.4-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.5-foo.1+0")] + [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.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.5-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.5-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.5-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.3-6+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-6+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.3-6+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-6+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.4-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.3-foo.1+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.4-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.4-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.5-foo.1+0")] + [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.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.5-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.5-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.5-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.3-foo.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-foo.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.3-foo.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [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.3-foo.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.3-foo.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.4-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.3-foo.3+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.4-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.4-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.5-foo.1+0")] + [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.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.5-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.5-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.4-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.5-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.3-bar.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-bar.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.3-bar.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.4-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.3-foo.1+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.4-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.5-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.5-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.5-foo.1+0")] + [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.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.4-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.5-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.5-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.5-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "2.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsBranchedToFeatureWhenFirstCommitTaggedAsPreReleaseBar.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsBranchedToFeatureWhenFirstCommitTaggedAsPreReleaseBar.cs new file mode 100644 index 0000000000..ddc87f80ed --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsBranchedToFeatureWhenFirstCommitTaggedAsPreReleaseBar.cs @@ -0,0 +1,489 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAMainBranchWithTwoCommitsBranchedToFeatureWhenFirstCommitTaggedAsPreReleaseBar + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 54 minutes ago (main) (HEAD -> feature/foo) + // A 56 minutes ago (0.0.3-bar) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.ApplyTag("0.0.3-bar"); + fixture.MakeACommit("B"); + fixture.BranchTo("feature/foo"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.3-bar+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.4-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.3-bar+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.3-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.3-bar+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.4-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.3-bar+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.4-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.3-foo.1+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.4-bar+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.5-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")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.5-bar+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.4-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.5-foo.1+0")] + [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.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.4-bar+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.5-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")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.5-bar+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.5-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-bar+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-bar+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.3-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.3-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.4-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.3-foo.1+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.4-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.4-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.5-foo.1+0")] + [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.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.5-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.5-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.5-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.3-foo.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-foo.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.3-foo.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [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.3-foo.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.3-foo.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.4-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.3-foo.3+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.4-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.4-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.5-foo.1+0")] + [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.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.5-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.5-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.4-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.5-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "2.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.3-bar+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.4-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.3-bar+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.3-bar+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.4-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.3-bar+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.4-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.3-foo.1+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.4-bar+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.5-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")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.5-bar+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.5-foo.1+0")] + [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.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.4-bar+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.5-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")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.5-bar+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.5-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-bar+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "foo", ExpectedResult = "0.3.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.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.2.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.3.0-foo.1+0")] + + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, null, ExpectedResult = "1.0.0-bar+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "foo", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "foo", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "2.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "2.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "3.0.0-foo.1+0")] + public string GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsBranchedToFeatureWhenFirstCommitTaggedAsPreReleaseFoo.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsBranchedToFeatureWhenFirstCommitTaggedAsPreReleaseFoo.cs new file mode 100644 index 0000000000..9136a86378 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsBranchedToFeatureWhenFirstCommitTaggedAsPreReleaseFoo.cs @@ -0,0 +1,489 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAMainBranchWithTwoCommitsBranchedToFeatureWhenFirstCommitTaggedAsPreReleaseFoo + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 54 minutes ago (main) (HEAD -> feature/foo) + // A 56 minutes ago (0.0.3-foo.4) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.ApplyTag("0.0.3-foo.4"); + fixture.MakeACommit("B"); + fixture.BranchTo("feature/foo"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.3-foo.6+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-foo.6+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.3-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.3-foo.6+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [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.3-foo.6+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.3-foo.6+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.4-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.3-foo.6+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.4-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.4-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.4-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.5-foo.1+0")] + [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.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.5-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.5-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.4-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.5-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.3-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.3-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.4-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.3-foo.1+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.4-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.4-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.5-foo.1+0")] + [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.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.5-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.5-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.5-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.3-foo.6+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-foo.6+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.3-foo.6+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [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.3-foo.6+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.3-foo.6+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.4-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.3-foo.6+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.4-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.4-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.5-foo.1+0")] + [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.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.5-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.5-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.4-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.5-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.3-bar.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-bar.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.3-bar.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.3+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.4-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.3-foo.1+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.4-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.5-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.5-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.5-foo.1+0")] + [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.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.4-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.5-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.5-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.5-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.2.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.2.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.3.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.2.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.3.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "2.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "2.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "2.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "3.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "2.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "2.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "2.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "3.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsBranchedToFeatureWhenFirstCommitTaggedAsStable.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsBranchedToFeatureWhenFirstCommitTaggedAsStable.cs new file mode 100644 index 0000000000..ddce4c502d --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsBranchedToFeatureWhenFirstCommitTaggedAsStable.cs @@ -0,0 +1,489 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAMainBranchWithTwoCommitsBranchedToFeatureWhenFirstCommitTaggedAsStable + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)) + .WithBranch("feature", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment).WithIsMainBranch(false)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 54 minutes ago (main) (HEAD -> feature/foo) + // A 56 minutes ago (0.0.3) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.ApplyTag("0.0.3"); + fixture.MakeACommit("B"); + fixture.BranchTo("feature/foo"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.3-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.3-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.4-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.3-foo.1+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.4-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.4-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.5-foo.1+0")] + [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.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.5-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.5-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.5-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithNoLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(null)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.3-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.3-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.4-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.3-foo.1+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.4-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.4-2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.5-foo.1+0")] + [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.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.5-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.5-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.5-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithEmptyLabelOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel(string.Empty)) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.3-foo.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-foo.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.3-foo.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [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.3-foo.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.3-foo.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.4-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.3-foo.2+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.4-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.4-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.5-foo.1+0")] + [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.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.5-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.5-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.4-foo.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.5-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithLabelFooOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("foo")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, IncrementStrategy.None, null, ExpectedResult = "0.0.3-bar.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, null, ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.3-bar.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "", ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.3-1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "foo", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [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.3-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "bar", ExpectedResult = "0.0.3-bar.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.4-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.3-bar.2+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.3-foo.1+0")] + [TestCase(IncrementStrategy.None, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.4-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.3-foo.1+0")] + + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, null, ExpectedResult = "0.0.4-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, null, ExpectedResult = "0.0.5-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, null, ExpectedResult = "0.0.5-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "", ExpectedResult = "0.0.4-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "", ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "", ExpectedResult = "0.0.5-1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "foo", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.5-foo.1+0")] + [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.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "bar", ExpectedResult = "0.0.4-bar.2+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.5-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.0.5-bar.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.0.4-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.0.5-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Major, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Patch, IncrementStrategy.Inherit, "{BranchName}", ExpectedResult = "0.0.5-foo.1+0")] + + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, null, ExpectedResult = "0.1.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, null, ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "", ExpectedResult = "0.2.0-1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+0")] + [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.1.0-bar.2+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Inherit, "bar", ExpectedResult = "0.2.0-bar.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.None, "{BranchName}", ExpectedResult = "0.1.0-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "0.1.1-foo.1+0")] + [TestCase(IncrementStrategy.Minor, IncrementStrategy.Minor, "{BranchName}", ExpectedResult = "0.2.0-foo.1+0")] + [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 = "1.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, null, ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "", ExpectedResult = "2.0.0-1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+0")] + [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 = "1.0.0-bar.2+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Inherit, "bar", ExpectedResult = "2.0.0-bar.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.None, "{BranchName}", ExpectedResult = "1.0.0-foo.1+0")] + [TestCase(IncrementStrategy.Major, IncrementStrategy.Patch, "{BranchName}", ExpectedResult = "1.0.1-foo.1+0")] + [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 GetVersionWithLabelBarOnMain(IncrementStrategy incrementOnMain, IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(incrementOnMain).WithLabel("bar")) + .WithBranch("feature", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhen.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhen.cs new file mode 100644 index 0000000000..dfbf6f5977 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhen.cs @@ -0,0 +1,62 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAMainBranchWithTwoCommitsWhen + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 58 minutes ago (HEAD -> main) + // A 59 minutes ago + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.MakeACommit("B"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + public string GetVersion(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenFirstCommitHasBumpMessageMajor.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenFirstCommitHasBumpMessageMajor.cs new file mode 100644 index 0000000000..3ed0c7586e --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenFirstCommitHasBumpMessageMajor.cs @@ -0,0 +1,120 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAMainBranchWithTwoCommitsWhenFirstCommitHasBumpMessageMajor + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 58 minutes ago (HEAD -> main) + // A 59 minutes ago + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A +semver: major"); + fixture.MakeACommit("B"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "1.0.0-2+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "1.0.1-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "1.1.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "1.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "1.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + public string GetVersion(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + public string GetVersionWithDisabledMessageIncrementing(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + public string GetVersionWithMergeMessageOnlyIncrementing(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenFirstCommitHasBumpMessageMinor.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenFirstCommitHasBumpMessageMinor.cs new file mode 100644 index 0000000000..e5ff33cfe0 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenFirstCommitHasBumpMessageMinor.cs @@ -0,0 +1,120 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAMainBranchWithTwoCommitsWhenFirstCommitHasBumpMessageMinor + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 58 minutes ago (HEAD -> main) + // A 59 minutes ago + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A +semver: minor"); + fixture.MakeACommit("B"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.1.0-2+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.1.1-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.2+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.1-foo.1+1")] + [TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.2+1")] + [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.1-bar.1+1")] + [TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + public string GetVersion(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + public string GetVersionWithDisabledMessageIncrementing(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + public string GetVersionWithMergeMessageOnlyIncrementing(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenFirstCommitHasBumpMessagePatch.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenFirstCommitHasBumpMessagePatch.cs new file mode 100644 index 0000000000..f4db1d0fa5 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenFirstCommitHasBumpMessagePatch.cs @@ -0,0 +1,120 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAMainBranchWithTwoCommitsWhenFirstCommitHasBumpMessagePatch + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 58 minutes ago (HEAD -> main) + // A 59 minutes ago + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A +semver: patch"); + fixture.MakeACommit("B"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.1-2+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.2+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.2+1")] + [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + public string GetVersion(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + public string GetVersionWithDisabledMessageIncrementing(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + public string GetVersionWithMergeMessageOnlyIncrementing(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenFirstCommitTaggedAsPreRelease.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenFirstCommitTaggedAsPreRelease.cs new file mode 100644 index 0000000000..ca9bc165d1 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenFirstCommitTaggedAsPreRelease.cs @@ -0,0 +1,63 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAMainBranchWithTwoCommitsWhenFirstCommitTaggedAsPreRelease + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 58 minutes ago (HEAD -> main) + // A 59 minutes ago (tag 0.0.3-4) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.ApplyTag("0.0.3-4"); + fixture.MakeACommit("B"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.3-5+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.4-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.3-5+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.4-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.3-foo.2+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.4-foo.1+1")] + [TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.0.3-bar.2+1")] + [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.4-bar.1+1")] + [TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + public string GetVersion(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenFirstCommitTaggedAsPreReleaseBar.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenFirstCommitTaggedAsPreReleaseBar.cs new file mode 100644 index 0000000000..2b01bedaff --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenFirstCommitTaggedAsPreReleaseBar.cs @@ -0,0 +1,63 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAMainBranchWithTwoCommitsWhenFirstCommitTaggedAsPreReleaseBar + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 58 minutes ago (HEAD -> main) + // A 59 minutes ago (tag 0.0.3-bar) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.ApplyTag("0.0.3-bar"); + fixture.MakeACommit("B"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.3-bar+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.4-bar+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-bar+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "1.0.0-bar+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.3-2+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.4-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.3-foo.2+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.4-foo.1+1")] + [TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.0.3-bar+1")] + [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.4-bar+1")] + [TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.1.0-bar+1")] + [TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "1.0.0-bar+1")] + public string GetVersion(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenFirstCommitTaggedAsPreReleaseFoo.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenFirstCommitTaggedAsPreReleaseFoo.cs new file mode 100644 index 0000000000..ec7c08a1bd --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenFirstCommitTaggedAsPreReleaseFoo.cs @@ -0,0 +1,63 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAMainBranchWithTwoCommitsWhenFirstCommitTaggedAsPreReleaseFoo + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 58 minutes ago (HEAD -> main) + // A 59 minutes ago (tag 0.0.3-foo.4) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.ApplyTag("0.0.3-foo.4"); + fixture.MakeACommit("B"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.3-foo.5+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.4-foo.1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "1.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.3-2+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.4-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.3-foo.5+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.4-foo.1+1")] + [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.3-bar.2+1")] + [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.4-bar.1+1")] + [TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + public string GetVersion(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenFirstCommitTaggedAsStable.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenFirstCommitTaggedAsStable.cs new file mode 100644 index 0000000000..2218e0717d --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenFirstCommitTaggedAsStable.cs @@ -0,0 +1,63 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAMainBranchWithTwoCommitsWhenFirstCommitTaggedAsStable + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 58 minutes ago (HEAD -> main) + // A 59 minutes ago (tag 0.0.3) + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.ApplyTag("0.0.3"); + fixture.MakeACommit("B"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.3-1+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.4-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.3-1+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.4-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "1.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.3-foo.1+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.4-foo.1+1")] + [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.3-bar.1+1")] + [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.4-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 GetVersion(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenSecondCommitHasBumpMessageMajor.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenSecondCommitHasBumpMessageMajor.cs new file mode 100644 index 0000000000..23a55ce78e --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenSecondCommitHasBumpMessageMajor.cs @@ -0,0 +1,120 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAMainBranchWithTwoCommitsWhenSecondCommitHasBumpMessageMajor + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 58 minutes ago (HEAD -> main) + // A 59 minutes ago + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.MakeACommit("B +semver: major"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "1.0.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "1.0.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.None, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "1.0.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + public string GetVersion(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + public string GetVersionWithDisabledMessageIncrementing(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + public string GetVersionWithMergeMessageOnlyIncrementing(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenSecondCommitHasBumpMessageMinor.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenSecondCommitHasBumpMessageMinor.cs new file mode 100644 index 0000000000..fa662a249c --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenSecondCommitHasBumpMessageMinor.cs @@ -0,0 +1,120 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAMainBranchWithTwoCommitsWhenSecondCommitHasBumpMessageMinor + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 58 minutes ago (HEAD -> main) + // A 59 minutes ago + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.MakeACommit("B +semver: minor"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.1.0-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.1.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.1.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + public string GetVersion(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + public string GetVersionWithDisabledMessageIncrementing(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + public string GetVersionWithMergeMessageOnlyIncrementing(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenSecondCommitHasBumpMessagePatch.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenSecondCommitHasBumpMessagePatch.cs new file mode 100644 index 0000000000..d956afcb4f --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenSecondCommitHasBumpMessagePatch.cs @@ -0,0 +1,120 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAMainBranchWithTwoCommitsWhenSecondCommitHasBumpMessagePatch + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 58 minutes ago (HEAD -> main) + // A 59 minutes ago + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.MakeACommit("B +semver: patch"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.1-1+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.1-foo.1+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.0.1-bar.1+1")] + [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + public string GetVersion(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + public string GetVersionWithDisabledMessageIncrementing(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.Disabled) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.0.0-2+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.0.2-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.0.0-foo.2+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.0.2-foo.1+1")] + [TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.0.0-bar.2+1")] + [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.0.2-bar.1+1")] + [TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + public string GetVersionWithMergeMessageOnlyIncrementing(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label) + .WithCommitMessageIncrementing(CommitMessageIncrementMode.MergeMessageOnly) + ).Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenSecondCommitTaggedAsPreRelease.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenSecondCommitTaggedAsPreRelease.cs new file mode 100644 index 0000000000..ab214954d7 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenSecondCommitTaggedAsPreRelease.cs @@ -0,0 +1,63 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAMainBranchWithTwoCommitsWhenSecondCommitTaggedAsPreRelease + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 58 minutes ago (HEAD -> main) (tag 0.2.0-4) + // A 59 minutes ago + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.MakeACommit("B"); + fixture.ApplyTag("0.2.0-4"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.2.0-4")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.2.0-4")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-4")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "0.2.0-4")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.2.0-4")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.2.0-4")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-4")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "0.2.0-4")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.2+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.2+1")] + [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + public string GetVersion(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenSecondCommitTaggedAsPreReleaseBar.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenSecondCommitTaggedAsPreReleaseBar.cs new file mode 100644 index 0000000000..3c2cd46deb --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenSecondCommitTaggedAsPreReleaseBar.cs @@ -0,0 +1,63 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAMainBranchWithTwoCommitsWhenSecondCommitTaggedAsPreReleaseBar + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 58 minutes ago (HEAD -> main) (tag 0.2.0-bar) + // A 59 minutes ago + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.MakeACommit("B"); + fixture.ApplyTag("0.2.0-bar"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.2.0-bar")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.2.0-bar")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-bar")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "0.2.0-bar")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.2.0-2+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.2+1")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.1+1")] + [TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "2.0.0-foo.1+1")] + + [TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar")] + [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.0-bar")] + [TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar")] + [TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "0.2.0-bar")] + public string GetVersion(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenSecondCommitTaggedAsPreReleaseFoo.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenSecondCommitTaggedAsPreReleaseFoo.cs new file mode 100644 index 0000000000..cfdef73874 --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenSecondCommitTaggedAsPreReleaseFoo.cs @@ -0,0 +1,63 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAMainBranchWithTwoCommitsWhenSecondCommitTaggedAsPreReleaseFoo + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 58 minutes ago (HEAD -> main) (tag 0.2.0-foo.4) + // A 59 minutes ago + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.MakeACommit("B"); + fixture.ApplyTag("0.2.0-foo.4"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.2.0-foo.4")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.2.0-foo.4")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.2.0-foo.4")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "0.2.0-foo.4")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.2.0-2+1")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.2.0-1+1")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "2.0.0-1+1")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.2.0-foo.4")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.0-foo.4")] + [TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0-foo.4")] + [TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "0.2.0-foo.4")] + + [TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.2.0-bar.2+1")] + [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0-bar.1+1")] + [TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "2.0.0-bar.1+1")] + public string GetVersion(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenSecondCommitTaggedAsStable.cs b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenSecondCommitTaggedAsStable.cs new file mode 100644 index 0000000000..d72069263c --- /dev/null +++ b/src/GitVersion.Core.Tests/TrunkBased/TrunkBasedScenariosWithAGitHubFlow+GivenAMainBranchWithTwoCommitsWhenSecondCommitTaggedAsStable.cs @@ -0,0 +1,63 @@ +using GitVersion.Configuration; +using GitVersion.Core.Tests; +using GitVersion.Core.Tests.IntegrationTests; +using GitVersion.VersionCalculation; + +namespace GitVersion.Core.TrunkBased; + +internal partial class TrunkBasedScenariosWithAGitHubFlow +{ + [Parallelizable(ParallelScope.All)] + public class GivenAMainBranchWithTwoCommitsWhenSecondCommitTaggedAsStable + { + private EmptyRepositoryFixture? fixture; + + private static GitHubFlowConfigurationBuilder TrunkBasedBuilder => GitHubFlowConfigurationBuilder.New + .WithVersionStrategy(VersionStrategies.TrunkBased).WithLabel(null) + .WithBranch("main", _ => _.WithDeploymentMode(DeploymentMode.ManualDeployment)); + + [OneTimeSetUp] + public void OneTimeSetUp() + { + // B 58 minutes ago (HEAD -> main) (tag 0.2.0) + // A 59 minutes ago + + fixture = new EmptyRepositoryFixture("main"); + + fixture.MakeACommit("A"); + fixture.MakeACommit("B"); + fixture.ApplyTag("0.2.0"); + } + + [OneTimeTearDown] + public void OneTimeTearDown() => fixture?.Dispose(); + + [TestCase(IncrementStrategy.None, null, ExpectedResult = "0.2.0")] + [TestCase(IncrementStrategy.Patch, null, ExpectedResult = "0.2.0")] + [TestCase(IncrementStrategy.Minor, null, ExpectedResult = "0.2.0")] + [TestCase(IncrementStrategy.Major, null, ExpectedResult = "0.2.0")] + + [TestCase(IncrementStrategy.None, "", ExpectedResult = "0.2.0")] + [TestCase(IncrementStrategy.Patch, "", ExpectedResult = "0.2.0")] + [TestCase(IncrementStrategy.Minor, "", ExpectedResult = "0.2.0")] + [TestCase(IncrementStrategy.Major, "", ExpectedResult = "0.2.0")] + + [TestCase(IncrementStrategy.None, "foo", ExpectedResult = "0.2.0")] + [TestCase(IncrementStrategy.Patch, "foo", ExpectedResult = "0.2.0")] + [TestCase(IncrementStrategy.Minor, "foo", ExpectedResult = "0.2.0")] + [TestCase(IncrementStrategy.Major, "foo", ExpectedResult = "0.2.0")] + + [TestCase(IncrementStrategy.None, "bar", ExpectedResult = "0.2.0")] + [TestCase(IncrementStrategy.Patch, "bar", ExpectedResult = "0.2.0")] + [TestCase(IncrementStrategy.Minor, "bar", ExpectedResult = "0.2.0")] + [TestCase(IncrementStrategy.Major, "bar", ExpectedResult = "0.2.0")] + public string GetVersion(IncrementStrategy increment, string? label) + { + IGitVersionConfiguration trunkBased = TrunkBasedBuilder + .WithBranch("main", _ => _.WithIncrement(increment).WithLabel(label)) + .Build(); + + return fixture!.GetVersion(trunkBased).FullSemVer; + } + } +} diff --git a/src/GitVersion.Core.Tests/VersionCalculation/EffectiveBranchConfigurationFinderTests.cs b/src/GitVersion.Core.Tests/VersionCalculation/EffectiveBranchConfigurationFinderTests.cs index 1055e06f55..3d754c8afe 100644 --- a/src/GitVersion.Core.Tests/VersionCalculation/EffectiveBranchConfigurationFinderTests.cs +++ b/src/GitVersion.Core.Tests/VersionCalculation/EffectiveBranchConfigurationFinderTests.cs @@ -156,7 +156,6 @@ public void UsesFirstBranchConfigWhenMultipleMatch(string branchName, IncrementS var releaseBranchMock = GitToolsTestingExtensions.CreateMockBranch(branchName, GitToolsTestingExtensions.CreateMockCommit()); var branchConfiguration = new BranchConfiguration { - DeploymentMode = DeploymentMode.TrunkBased, Increment = IncrementStrategy.None, PreventIncrementOfMergedBranchVersion = false, TrackMergeTarget = false, diff --git a/src/GitVersion.Core/Configuration/ConfigurationConstants.cs b/src/GitVersion.Core/Configuration/ConfigurationConstants.cs index c0296ee261..a3d7f28e1b 100644 --- a/src/GitVersion.Core/Configuration/ConfigurationConstants.cs +++ b/src/GitVersion.Core/Configuration/ConfigurationConstants.cs @@ -1,4 +1,5 @@ using GitVersion.Extensions; +using GitVersion.VersionCalculation; namespace GitVersion.Configuration; @@ -13,6 +14,7 @@ internal static class ConfigurationConstants public const AssemblyVersioningScheme DefaultAssemblyVersioningScheme = AssemblyVersioningScheme.MajorMinorPatch; public const AssemblyFileVersioningScheme DefaultAssemblyFileVersioningScheme = AssemblyFileVersioningScheme.MajorMinorPatch; public const SemanticVersionFormat DefaultSemanticVersionFormat = SemanticVersionFormat.Strict; + public const VersionStrategies DefaultVersionStrategy = VersionStrategies.NonTrunkBased; public const string DefaultAssemblyInformationalFormat = "{InformationalVersion}"; public const string DefaultTagPrefix = "[vV]?"; public const string DefaultVersionInBranchPattern = @"(?[vV]?\d+(\.\d+)?(\.\d+)?).*"; diff --git a/src/GitVersion.Core/Configuration/EffectiveConfiguration.cs b/src/GitVersion.Core/Configuration/EffectiveConfiguration.cs index f3d8a9b295..6482eb5b16 100644 --- a/src/GitVersion.Core/Configuration/EffectiveConfiguration.cs +++ b/src/GitVersion.Core/Configuration/EffectiveConfiguration.cs @@ -61,6 +61,7 @@ public EffectiveConfiguration(IGitVersionConfiguration configuration, IBranchCon CommitDateFormat = configuration.CommitDateFormat; UpdateBuildNumber = configuration.UpdateBuildNumber; SemanticVersionFormat = configuration.SemanticVersionFormat; + VersionStrategy = configuration.VersionStrategy; PreReleaseWeight = branchConfiguration.PreReleaseWeight ?? 0; TagPreReleaseWeight = configuration.TagPreReleaseWeight.Value; } @@ -176,7 +177,9 @@ protected EffectiveConfiguration(AssemblyVersioningScheme assemblyVersioningSche public bool UpdateBuildNumber { get; } - public SemanticVersionFormat SemanticVersionFormat { get; set; } + public SemanticVersionFormat SemanticVersionFormat { get; } + + public VersionStrategies VersionStrategy { get; } public int PreReleaseWeight { get; } diff --git a/src/GitVersion.Core/Configuration/IGitVersionConfiguration.cs b/src/GitVersion.Core/Configuration/IGitVersionConfiguration.cs index 37d7bf8ce9..47a5db9e31 100644 --- a/src/GitVersion.Core/Configuration/IGitVersionConfiguration.cs +++ b/src/GitVersion.Core/Configuration/IGitVersionConfiguration.cs @@ -1,5 +1,6 @@ using System.Text.RegularExpressions; using GitVersion.Extensions; +using GitVersion.VersionCalculation; namespace GitVersion.Configuration; @@ -43,6 +44,8 @@ public interface IGitVersionConfiguration : IBranchConfiguration SemanticVersionFormat SemanticVersionFormat { get; } + VersionStrategies VersionStrategy { get; } + IReadOnlyDictionary Branches { get; } IIgnoreConfiguration Ignore { get; } diff --git a/src/GitVersion.Core/PublicAPI.Unshipped.txt b/src/GitVersion.Core/PublicAPI.Unshipped.txt index 86db54b030..c837f89a68 100644 --- a/src/GitVersion.Core/PublicAPI.Unshipped.txt +++ b/src/GitVersion.Core/PublicAPI.Unshipped.txt @@ -144,13 +144,13 @@ GitVersion.Configuration.EffectiveConfiguration.PatchVersionBumpMessage.get -> s GitVersion.Configuration.EffectiveConfiguration.PreReleaseWeight.get -> int GitVersion.Configuration.EffectiveConfiguration.PreventIncrementOfMergedBranchVersion.get -> bool GitVersion.Configuration.EffectiveConfiguration.SemanticVersionFormat.get -> GitVersion.SemanticVersionFormat -GitVersion.Configuration.EffectiveConfiguration.SemanticVersionFormat.set -> void GitVersion.Configuration.EffectiveConfiguration.TrackMergeMessage.get -> bool GitVersion.Configuration.EffectiveConfiguration.TrackMergeTarget.get -> bool GitVersion.Configuration.EffectiveConfiguration.TracksReleaseBranches.get -> bool GitVersion.Configuration.EffectiveConfiguration.UpdateBuildNumber.get -> bool GitVersion.Configuration.EffectiveConfiguration.VersionFilters.get -> System.Collections.Generic.IEnumerable! GitVersion.Configuration.EffectiveConfiguration.VersionInBranchRegex.get -> System.Text.RegularExpressions.Regex! +GitVersion.Configuration.EffectiveConfiguration.VersionStrategy.get -> GitVersion.VersionCalculation.VersionStrategies GitVersion.Configuration.IBranchConfiguration GitVersion.Configuration.IBranchConfiguration.CommitMessageIncrementing.get -> GitVersion.VersionCalculation.CommitMessageIncrementMode? GitVersion.Configuration.IBranchConfiguration.DeploymentMode.get -> GitVersion.VersionCalculation.DeploymentMode? @@ -200,6 +200,7 @@ GitVersion.Configuration.IGitVersionConfiguration.ToJsonString() -> string! GitVersion.Configuration.IGitVersionConfiguration.UpdateBuildNumber.get -> bool GitVersion.Configuration.IGitVersionConfiguration.VersionInBranchPattern.get -> string? GitVersion.Configuration.IGitVersionConfiguration.VersionInBranchRegex.get -> System.Text.RegularExpressions.Regex! +GitVersion.Configuration.IGitVersionConfiguration.VersionStrategy.get -> GitVersion.VersionCalculation.VersionStrategies GitVersion.Configuration.IGitVersionConfiguration.Workflow.get -> string? GitVersion.Configuration.IIgnoreConfiguration GitVersion.Configuration.IIgnoreConfiguration.Before.get -> System.DateTimeOffset? @@ -694,7 +695,6 @@ GitVersion.VersionCalculation.DeploymentMode GitVersion.VersionCalculation.DeploymentMode.ContinuousDelivery = 1 -> GitVersion.VersionCalculation.DeploymentMode GitVersion.VersionCalculation.DeploymentMode.ContinuousDeployment = 2 -> GitVersion.VersionCalculation.DeploymentMode GitVersion.VersionCalculation.DeploymentMode.ManualDeployment = 0 -> GitVersion.VersionCalculation.DeploymentMode -GitVersion.VersionCalculation.DeploymentMode.TrunkBased = 3 -> GitVersion.VersionCalculation.DeploymentMode GitVersion.VersionCalculation.IEffectiveBranchConfigurationFinder GitVersion.VersionCalculation.IEffectiveBranchConfigurationFinder.GetConfigurations(GitVersion.IBranch! branch, GitVersion.Configuration.IGitVersionConfiguration! configuration) -> System.Collections.Generic.IEnumerable! GitVersion.VersionCalculation.IIncrementStrategyFinder @@ -723,6 +723,15 @@ GitVersion.VersionCalculation.NextVersion.NextVersion(GitVersion.SemanticVersion GitVersion.VersionCalculation.VersionCalculationModule GitVersion.VersionCalculation.VersionCalculationModule.RegisterTypes(Microsoft.Extensions.DependencyInjection.IServiceCollection! services) -> void GitVersion.VersionCalculation.VersionCalculationModule.VersionCalculationModule() -> void +GitVersion.VersionCalculation.VersionStrategies +GitVersion.VersionCalculation.VersionStrategies.ConfigNext = 1 -> GitVersion.VersionCalculation.VersionStrategies +GitVersion.VersionCalculation.VersionStrategies.MergeMessage = 2 -> GitVersion.VersionCalculation.VersionStrategies +GitVersion.VersionCalculation.VersionStrategies.None = 0 -> GitVersion.VersionCalculation.VersionStrategies +GitVersion.VersionCalculation.VersionStrategies.NonTrunkBased = GitVersion.VersionCalculation.VersionStrategies.ConfigNext | GitVersion.VersionCalculation.VersionStrategies.MergeMessage | GitVersion.VersionCalculation.VersionStrategies.TaggedCommit | GitVersion.VersionCalculation.VersionStrategies.TrackReleaseBranches | GitVersion.VersionCalculation.VersionStrategies.VersionInBranchName -> GitVersion.VersionCalculation.VersionStrategies +GitVersion.VersionCalculation.VersionStrategies.TaggedCommit = 4 -> GitVersion.VersionCalculation.VersionStrategies +GitVersion.VersionCalculation.VersionStrategies.TrackReleaseBranches = 8 -> GitVersion.VersionCalculation.VersionStrategies +GitVersion.VersionCalculation.VersionStrategies.TrunkBased = 32 -> GitVersion.VersionCalculation.VersionStrategies +GitVersion.VersionCalculation.VersionStrategies.VersionInBranchName = 16 -> GitVersion.VersionCalculation.VersionStrategies GitVersion.VersionCalculation.VersionStrategyBase GitVersion.VersionCalculation.VersionStrategyBase.Context.get -> GitVersion.GitVersionContext! GitVersion.VersionCalculation.VersionStrategyBase.VersionStrategyBase(System.Lazy! versionContext) -> void diff --git a/src/GitVersion.Core/VersionCalculation/DeploymentMode.cs b/src/GitVersion.Core/VersionCalculation/DeploymentMode.cs index def5b72b1c..e6fa322591 100644 --- a/src/GitVersion.Core/VersionCalculation/DeploymentMode.cs +++ b/src/GitVersion.Core/VersionCalculation/DeploymentMode.cs @@ -4,6 +4,5 @@ public enum DeploymentMode { ManualDeployment, ContinuousDelivery, - ContinuousDeployment, - TrunkBased + ContinuousDeployment } diff --git a/src/GitVersion.Core/VersionCalculation/VersionSearchStrategies/ConfigNextVersionVersionStrategy.cs b/src/GitVersion.Core/VersionCalculation/VersionSearchStrategies/ConfigNextVersionVersionStrategy.cs index ce74043e45..0062ebac40 100644 --- a/src/GitVersion.Core/VersionCalculation/VersionSearchStrategies/ConfigNextVersionVersionStrategy.cs +++ b/src/GitVersion.Core/VersionCalculation/VersionSearchStrategies/ConfigNextVersionVersionStrategy.cs @@ -12,6 +12,9 @@ internal class ConfigNextVersionVersionStrategy(Lazy versionC { public override IEnumerable GetBaseVersions(EffectiveBranchConfiguration configuration) { + if (!Context.Configuration.VersionStrategy.HasFlag(VersionStrategies.ConfigNext)) + yield break; + var contextConfiguration = Context.Configuration; var nextVersion = contextConfiguration.NextVersion; if (!nextVersion.IsNullOrEmpty() && !Context.IsCurrentCommitTagged) diff --git a/src/GitVersion.Core/VersionCalculation/VersionSearchStrategies/MergeMessageVersionStrategy.cs b/src/GitVersion.Core/VersionCalculation/VersionSearchStrategies/MergeMessageVersionStrategy.cs index 5477d80310..00ef491390 100644 --- a/src/GitVersion.Core/VersionCalculation/VersionSearchStrategies/MergeMessageVersionStrategy.cs +++ b/src/GitVersion.Core/VersionCalculation/VersionSearchStrategies/MergeMessageVersionStrategy.cs @@ -19,7 +19,7 @@ internal class MergeMessageVersionStrategy(ILog log, Lazy ver public override IEnumerable GetBaseVersions(EffectiveBranchConfiguration configuration) { - if (!configuration.Value.TrackMergeMessage || Context.Configuration.DeploymentMode == DeploymentMode.TrunkBased) + if (!Context.Configuration.VersionStrategy.HasFlag(VersionStrategies.MergeMessage) || !configuration.Value.TrackMergeMessage) return []; var commitsPriorToThan = Context.CurrentBranch.Commits.GetCommitsPriorTo(Context.CurrentCommit.When); diff --git a/src/GitVersion.Core/VersionCalculation/VersionSearchStrategies/TaggedCommitVersionStrategy.cs b/src/GitVersion.Core/VersionCalculation/VersionSearchStrategies/TaggedCommitVersionStrategy.cs index 7b51852061..6fedc16132 100644 --- a/src/GitVersion.Core/VersionCalculation/VersionSearchStrategies/TaggedCommitVersionStrategy.cs +++ b/src/GitVersion.Core/VersionCalculation/VersionSearchStrategies/TaggedCommitVersionStrategy.cs @@ -15,7 +15,7 @@ internal sealed class TaggedCommitVersionStrategy(ITaggedSemanticVersionReposito private readonly ITaggedSemanticVersionRepository taggedSemanticVersionRepository = taggedSemanticVersionRepository.NotNull(); public override IEnumerable GetBaseVersions(EffectiveBranchConfiguration configuration) - => Context.Configuration.DeploymentMode == DeploymentMode.TrunkBased ? [] + => !Context.Configuration.VersionStrategy.HasFlag(VersionStrategies.TaggedCommit) ? [] : GetTaggedSemanticVersions(configuration).Select(CreateBaseVersion); private IEnumerable GetTaggedSemanticVersions(EffectiveBranchConfiguration configuration) diff --git a/src/GitVersion.Core/VersionCalculation/VersionSearchStrategies/TrackReleaseBranchesVersionStrategy.cs b/src/GitVersion.Core/VersionCalculation/VersionSearchStrategies/TrackReleaseBranchesVersionStrategy.cs index 1d3f88601b..1ef811eb6f 100644 --- a/src/GitVersion.Core/VersionCalculation/VersionSearchStrategies/TrackReleaseBranchesVersionStrategy.cs +++ b/src/GitVersion.Core/VersionCalculation/VersionSearchStrategies/TrackReleaseBranchesVersionStrategy.cs @@ -29,7 +29,8 @@ internal class TrackReleaseBranchesVersionStrategy(IRepositoryStore repositorySt public override IEnumerable GetBaseVersions(EffectiveBranchConfiguration configuration) { - if (Context.Configuration.DeploymentMode == DeploymentMode.TrunkBased) return []; + if (!Context.Configuration.VersionStrategy.HasFlag(VersionStrategies.TrackReleaseBranches)) + return []; return configuration.Value.TracksReleaseBranches ? ReleaseBranchBaseVersions() : []; } diff --git a/src/GitVersion.Core/VersionCalculation/VersionSearchStrategies/TrunkBasedVersionStrategy.cs b/src/GitVersion.Core/VersionCalculation/VersionSearchStrategies/TrunkBasedVersionStrategy.cs index 2052689c57..4a9bc16a63 100644 --- a/src/GitVersion.Core/VersionCalculation/VersionSearchStrategies/TrunkBasedVersionStrategy.cs +++ b/src/GitVersion.Core/VersionCalculation/VersionSearchStrategies/TrunkBasedVersionStrategy.cs @@ -66,7 +66,8 @@ internal sealed class TrunkBasedVersionStrategy( public override IEnumerable GetBaseVersions(EffectiveBranchConfiguration configuration) { - if (Context.Configuration.DeploymentMode != DeploymentMode.TrunkBased) yield break; + if (!Context.Configuration.VersionStrategy.HasFlag(VersionStrategies.TrunkBased)) + yield break; var iteration = CreateIteration(branchName: Context.CurrentBranch.Name, configuration: configuration.Value); diff --git a/src/GitVersion.Core/VersionCalculation/VersionSearchStrategies/VersionInBranchNameVersionStrategy.cs b/src/GitVersion.Core/VersionCalculation/VersionSearchStrategies/VersionInBranchNameVersionStrategy.cs index 0c9a1df281..bc7cfb215d 100644 --- a/src/GitVersion.Core/VersionCalculation/VersionSearchStrategies/VersionInBranchNameVersionStrategy.cs +++ b/src/GitVersion.Core/VersionCalculation/VersionSearchStrategies/VersionInBranchNameVersionStrategy.cs @@ -17,7 +17,8 @@ internal class VersionInBranchNameVersionStrategy(IRepositoryStore repositorySto public override IEnumerable GetBaseVersions(EffectiveBranchConfiguration configuration) { - if (Context.Configuration.DeploymentMode == DeploymentMode.TrunkBased) yield break; + if (!Context.Configuration.VersionStrategy.HasFlag(VersionStrategies.VersionInBranchName)) + yield break; if (configuration.Value.IsReleaseBranch && TryGetBaseVersion(out var baseVersion, configuration)) { diff --git a/src/GitVersion.Core/VersionCalculation/VersionStrategies.cs b/src/GitVersion.Core/VersionCalculation/VersionStrategies.cs new file mode 100644 index 0000000000..9937f108d1 --- /dev/null +++ b/src/GitVersion.Core/VersionCalculation/VersionStrategies.cs @@ -0,0 +1,14 @@ +namespace GitVersion.VersionCalculation; + +[Flags] +public enum VersionStrategies +{ + None = 0, + ConfigNext = 1, + MergeMessage = 2, + TaggedCommit = 4, + TrackReleaseBranches = 8, + VersionInBranchName = 16, + NonTrunkBased = ConfigNext | MergeMessage | TaggedCommit | TrackReleaseBranches | VersionInBranchName, + TrunkBased = 32, +}