Skip to content

Commit

Permalink
Rename ConfigNextVersionVersionStrategy to ConfiguredNextVersionVersi…
Browse files Browse the repository at this point in the history
…onStrategy
  • Loading branch information
HHobeck committed Jan 26, 2024
1 parent e8176a6 commit 948bc9e
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 59 deletions.
2 changes: 1 addition & 1 deletion BREAKING_CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
* ContinuousDelivery (previously ContinuousDeployment)
* ContinuousDeployment (new)
* At the configuration root level, a new array called `strategies` has been introduced, which can consist of on or more following values:
* ConfigNextVersion
* ConfiguredNextVersion
* MergeMessage
* TaggedCommit
* TrackReleaseBranches
Expand Down
69 changes: 26 additions & 43 deletions docs/input/docs/reference/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ The global configuration looks like this:
assembly-versioning-scheme: MajorMinorPatch
assembly-file-versioning-scheme: MajorMinorPatch
tag-prefix: '[vV]?'
version-in-branch-pattern: (?<version>[vV]?\d+(\.\d+)?(\.\d+)?).*
major-version-bump-message: '\+semver:\s?(breaking|major)'
minor-version-bump-message: '\+semver:\s?(feature|minor)'
patch-version-bump-message: '\+semver:\s?(fix|patch)'
Expand All @@ -53,30 +52,21 @@ commit-date-format: yyyy-MM-dd
merge-message-formats: {}
update-build-number: true
semantic-version-format: Strict
strategies:
- ConfigNextVersion
- MergeMessage
- TaggedCommit
- TrackReleaseBranches
- VersionInBranchName
strategies: [ConfigNext, MergeMessage, TaggedCommit, TrackReleaseBranches, VersionInBranchName]
branches:
develop:
tracks-release-branches: true
is-release-branch: false
is-main-branch: false
pre-release-weight: 0
mode: ContinuousDeployment
label: alpha
increment: Minor
prevent-increment-of-merged-branch-version: false
track-merge-target: true
regex: ^dev(elop)?(ment)?$
source-branches: []
is-source-branch-for: []
main:
tracks-release-branches: false
tracks-release-branches: true
is-release-branch: false
is-main-branch: true
pre-release-weight: 55000
is-main-branch: false
pre-release-weight: 0
main:
label: ''
increment: Patch
prevent-increment-of-merged-branch-version: true
Expand All @@ -85,13 +75,11 @@ branches:
source-branches:
- develop
- release
is-source-branch-for: []
release:
tracks-release-branches: false
is-release-branch: true
is-main-branch: false
pre-release-weight: 30000
mode: ManualDeployment
is-release-branch: false
is-main-branch: true
pre-release-weight: 55000
release:
label: beta
increment: None
prevent-increment-of-merged-branch-version: true
Expand All @@ -102,10 +90,12 @@ branches:
- main
- support
- release
is-source-branch-for: []
feature:
tracks-release-branches: false
is-release-branch: true
is-main-branch: false
pre-release-weight: 30000
mode: ManualDeployment
feature:
mode: ContinuousDelivery
label: '{BranchName}'
increment: Inherit
regex: ^features?[/-](?<BranchName>.+)
Expand All @@ -116,9 +106,8 @@ branches:
- feature
- support
- hotfix
is-source-branch-for: []
pull-request:
pre-release-weight: 30000
pull-request:
mode: ContinuousDelivery
label: PullRequest
increment: Inherit
Expand All @@ -131,11 +120,9 @@ branches:
- feature
- support
- hotfix
is-source-branch-for: []
hotfix:
is-release-branch: true
pre-release-weight: 30000
mode: ManualDeployment
hotfix:
mode: ContinuousDelivery
label: beta
increment: Inherit
regex: ^hotfix(es)?[/-]
Expand All @@ -144,25 +131,24 @@ branches:
- main
- support
- hotfix
is-source-branch-for: []
pre-release-weight: 30000
support:
tracks-release-branches: false
is-release-branch: false
is-main-branch: true
pre-release-weight: 55000
label: ''
increment: Patch
prevent-increment-of-merged-branch-version: true
track-merge-target: false
regex: ^support[/-]
source-branches:
- main
is-source-branch-for: []
tracks-release-branches: false
is-release-branch: false
is-main-branch: true
pre-release-weight: 55000
unknown:
mode: ManualDeployment
mode: ContinuousDelivery
label: '{BranchName}'
increment: Inherit
regex: (?<BranchName>.+)
regex: (?<BranchName>.*)
source-branches:
- main
- develop
Expand All @@ -171,7 +157,6 @@ branches:
- pull-request
- hotfix
- support
is-source-branch-for: []
ignore:
sha: []
mode: ContinuousDelivery
Expand All @@ -182,8 +167,6 @@ track-merge-target: false
track-merge-message: true
commit-message-incrementing: Enabled
regex: ''
source-branches: []
is-source-branch-for: []
tracks-release-branches: false
is-release-branch: false
is-main-branch: false
Expand Down Expand Up @@ -694,7 +677,7 @@ Example of invalid `Strict`, but valid `Loose`
### strategies
Specifies which version strategy implementation (one ore more) will be used to determine the next version. Following values are supported and can be combined:
* ConfigNextVersion
* ConfiguredNextVersion
* MergeMessage
* TaggedCommit
* TrackReleaseBranches
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ merge-message-formats: {}
update-build-number: true
semantic-version-format: Strict
strategies:
- ConfigNextVersion
- ConfiguredNextVersion
- MergeMessage
- TaggedCommit
- TrackReleaseBranches
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ public void OverwritesDefaultsWithProvidedConfig()
public void CombineVersionStrategyConfigNextAndTaggedCommit()
{
// Arrange
SetupConfigFileContent("strategies: [ConfigNextVersion, TaggedCommit]");
SetupConfigFileContent("strategies: [ConfiguredNextVersion, TaggedCommit]");

// Act
var configuration = this.configurationProvider.ProvideForDirectory(this.repoPath);

// Assert
configuration.VersionStrategy.ShouldBe(VersionStrategies.ConfigNextVersion | VersionStrategies.TaggedCommit);
configuration.VersionStrategy.ShouldBe(VersionStrategies.ConfiguredNextVersion | VersionStrategies.TaggedCommit);
}

[Test]
Expand Down
2 changes: 1 addition & 1 deletion src/GitVersion.Configuration/GitVersionConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public string? NextVersion
? VersionCalculation.VersionStrategies.None : VersionStrategies.Aggregate((one, another) => one | another);

[JsonPropertyName("strategies")]
[JsonPropertyDescription($"Specifies which version strategies (one or more) will be used to determine the next version. Following values are available: 'ConfigNextVersion', 'MergeMessage', 'TaggedCommit', 'TrackReleaseBranches', 'VersionInBranchName' and 'TrunkBased'.")]
[JsonPropertyDescription($"Specifies which version strategies (one or more) will be used to determine the next version. Following values are available: 'ConfiguredNextVersion', 'MergeMessage', 'TaggedCommit', 'TrackReleaseBranches', 'VersionInBranchName' and 'TrunkBased'.")]
public VersionStrategies[] VersionStrategies { get; internal set; } = [];

[JsonIgnore]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ commit-date-format: yyyy-MM-dd
merge-message-formats: {}
update-build-number: true
semantic-version-format: Strict
strategies: [TrunkBased, ConfigNextVersion]
strategies: [TrunkBased, ConfiguredNextVersion]
branches:
main:
mode: ContinuousDeployment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace GitVersion.Core.Tests.VersionCalculation.Strategies;

[TestFixture]
public class ConfigNextVersionBaseVersionStrategyTests : TestBase
public class ConfiguredNextVersionBaseVersionStrategyTests : TestBase
{
[Test]
public void ReturnsNullWhenNoNextVersionIsInConfig()
Expand All @@ -22,7 +22,7 @@ public void ReturnsNullWhenNoNextVersionIsInConfig()
[TestCase("2.12.654651698", "2.12.654651698", SemanticVersionFormat.Strict)]
[TestCase("2.12.654651698", "2.12.654651698", SemanticVersionFormat.Loose)]
[TestCase("0.1", "0.1.0", SemanticVersionFormat.Loose)]
public void ConfigNextVersionTest(string nextVersion, string expectedVersion, SemanticVersionFormat versionFormat)
public void ConfiguredNextVersionTest(string nextVersion, string expectedVersion, SemanticVersionFormat versionFormat)
{
var overrideConfiguration = new Dictionary<object, object?>
{
Expand All @@ -37,7 +37,7 @@ public void ConfigNextVersionTest(string nextVersion, string expectedVersion, Se
}

[TestCase("0.1", SemanticVersionFormat.Strict)]
public void ConfigNextVersionTestShouldFail(string nextVersion, SemanticVersionFormat versionFormat)
public void ConfiguredNextVersionTestShouldFail(string nextVersion, SemanticVersionFormat versionFormat)
{
var overrideConfiguration = new Dictionary<object, object?>
{
Expand All @@ -54,7 +54,7 @@ public void ConfigNextVersionTestShouldFail(string nextVersion, SemanticVersionF
var contextBuilder = new GitVersionContextBuilder().WithOverrideConfiguration(overrideConfiguration);
contextBuilder.Build();
contextBuilder.ServicesProvider.ShouldNotBeNull();
var strategy = contextBuilder.ServicesProvider.GetServiceForType<IVersionStrategy, ConfigNextVersionVersionStrategy>();
var strategy = contextBuilder.ServicesProvider.GetServiceForType<IVersionStrategy, ConfiguredNextVersionVersionStrategy>();
var context = contextBuilder.ServicesProvider.GetRequiredService<Lazy<GitVersionContext>>().Value;
var branchMock = GitToolsTestingExtensions.CreateMockBranch("main", GitToolsTestingExtensions.CreateMockCommit());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal static class ConfigurationConstants
public const AssemblyFileVersioningScheme DefaultAssemblyFileVersioningScheme = AssemblyFileVersioningScheme.MajorMinorPatch;
public const SemanticVersionFormat DefaultSemanticVersionFormat = SemanticVersionFormat.Strict;
public static readonly VersionStrategies[] DefaultVersionStrategies = [
VersionStrategies.ConfigNextVersion,
VersionStrategies.ConfiguredNextVersion,
VersionStrategies.MergeMessage,
VersionStrategies.TaggedCommit,
VersionStrategies.TrackReleaseBranches,
Expand Down
2 changes: 1 addition & 1 deletion src/GitVersion.Core/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ GitVersion.VersionCalculation.VersionCalculationModule
GitVersion.VersionCalculation.VersionCalculationModule.RegisterTypes(Microsoft.Extensions.DependencyInjection.IServiceCollection! services) -> void
GitVersion.VersionCalculation.VersionCalculationModule.VersionCalculationModule() -> void
GitVersion.VersionCalculation.VersionStrategies
GitVersion.VersionCalculation.VersionStrategies.ConfigNextVersion = 1 -> GitVersion.VersionCalculation.VersionStrategies
GitVersion.VersionCalculation.VersionStrategies.ConfiguredNextVersion = 1 -> GitVersion.VersionCalculation.VersionStrategies
GitVersion.VersionCalculation.VersionStrategies.MergeMessage = 2 -> GitVersion.VersionCalculation.VersionStrategies
GitVersion.VersionCalculation.VersionStrategies.None = 0 -> GitVersion.VersionCalculation.VersionStrategies
GitVersion.VersionCalculation.VersionStrategies.TaggedCommit = 4 -> GitVersion.VersionCalculation.VersionStrategies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ namespace GitVersion.VersionCalculation;
/// BaseVersionSource is null.
/// Does not increment.
/// </summary>
internal class ConfigNextVersionVersionStrategy(Lazy<GitVersionContext> versionContext) : VersionStrategyBase(versionContext)
internal class ConfiguredNextVersionVersionStrategy(Lazy<GitVersionContext> versionContext) : VersionStrategyBase(versionContext)
{
public override IEnumerable<BaseVersion> GetBaseVersions(EffectiveBranchConfiguration configuration)
{
if (!Context.Configuration.VersionStrategy.HasFlag(VersionStrategies.ConfigNextVersion))
if (!Context.Configuration.VersionStrategy.HasFlag(VersionStrategies.ConfiguredNextVersion))
yield break;

var contextConfiguration = Context.Configuration;
Expand Down
4 changes: 2 additions & 2 deletions src/GitVersion.Core/VersionCalculation/VersionStrategies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ namespace GitVersion.VersionCalculation;
public enum VersionStrategies
{
None = 0,
ConfigNextVersion = 1,
ConfiguredNextVersion = 1,
MergeMessage = 2,
TaggedCommit = 4,
TrackReleaseBranches = 8,
VersionInBranchName = 16,
TrunkBased = 32,
TrunkBased = 32
}

0 comments on commit 948bc9e

Please sign in to comment.