Skip to content

Replace the version mode Mainline in 6.x (Part III) #3882

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion BREAKING_CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@
* Default `RegularExpression` for feature branches is changed from `^features?[/-]` to `^features?[/-](?<BranchName>.+)` to support using `{BranchName}` out-of-the-box
* Default `RegularExpression` for unknown branches is changed from `.*` to `(?<BranchName>.*)` to support using `{BranchName}` out-of-the-box
* 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)

## v5.0.0

* Version numbers in branches other than `release` branches are no longer
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ We can then customize the configuration by chaining methods of the builder. At t
For example:
```csharp
var configuration = configurationBuilder
.WithVersioningMode(VersioningMode.ContinuousDeployment)
.WithDeploymentMode(DeploymentMode.ContinuousDeployment)
.WithNextVersion("1.0.0")
.Build();
```
Expand Down
2 changes: 1 addition & 1 deletion build/build/Tasks/Test/UnitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public override void OnError(Exception exception, BuildContext context)
public override void Finally(BuildContext context)
{
var testResultsFiles = context.GetFiles($"{Paths.TestOutput}/*.results.xml");
if (!context.IsAzurePipelineBuild || !testResultsFiles.Any()) return;
if (!context.IsAzurePipelineBuild || testResultsFiles.Count == 0) return;

var data = new AzurePipelinesPublishTestResultsData
{
Expand Down
2 changes: 1 addition & 1 deletion build/common/Utilities/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static string GetTaskArguments(this Type task)
}

var attributes = task.GetCustomAttributes<TaskArgumentAttribute>().ToArray();
if (attributes.Any())
if (attributes.Length != 0)
{
var arguments = attributes.Select(attribute => $"[--{attribute.Name} ({string.Join(" | ", attribute.PossibleValues)})]");
return string.Join(" ", arguments);
Expand Down
31 changes: 16 additions & 15 deletions schemas/6.0/GitVersion.configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
"commit-message-incrementing": {
"$ref": "#/$defs/nullableOfCommitMessageIncrementMode"
},
"mode": {
"$ref": "#/$defs/nullableOfDeploymentMode"
},
"ignore": {
"description": "The header property for the ignore configuration.",
"type": "object",
Expand Down Expand Up @@ -173,9 +176,6 @@
"default": "(?<version>[vV]?\\d+(\\.\\d+)?(\\.\\d+)?).*",
"type": "string"
},
"mode": {
"$ref": "#/$defs/nullableOfVersioningMode"
},
"workflow": {
"description": "The base template of the configuration to use. Possible values are: 'GitFlow/v1' or 'GitHubFlow/v1'",
"type": "string"
Expand All @@ -188,6 +188,9 @@
"commit-message-incrementing": {
"$ref": "#/$defs/nullableOfCommitMessageIncrementMode"
},
"mode": {
"$ref": "#/$defs/nullableOfDeploymentMode"
},
"increment": {
"$ref": "#/$defs/incrementStrategy"
},
Expand Down Expand Up @@ -226,9 +229,6 @@
},
"tracks-release-branches": {
"$ref": "#/$defs/nullableOfBoolean5"
},
"mode": {
"$ref": "#/$defs/nullableOfVersioningMode"
}
}
},
Expand All @@ -240,6 +240,15 @@
"MergeMessageOnly"
]
},
"nullableOfDeploymentMode": {
"description": "The deployment mode for this branch. Can be 'ManualDeployment', 'ContinuousDelivery', 'ContinuousDeployment'.",
"enum": [
"ManualDeployment",
"ContinuousDelivery",
"ContinuousDeployment",
"TrunkBased"
]
},
"incrementStrategy": {
"description": "The increment strategy for this branch. Can be 'Inherit', 'Patch', 'Minor', 'Major', 'None'.",
"enum": [
Expand Down Expand Up @@ -330,14 +339,6 @@
"null"
]
},
"nullableOfVersioningMode": {
"description": "The versioning mode for this branch. Can be 'ContinuousDelivery', 'ContinuousDeployment', 'Mainline'.",
"enum": [
"ContinuousDelivery",
"ContinuousDeployment",
"Mainline"
]
},
"string3": {
"format": "date-time",
"description": "Commits before this date will be ignored. Format: yyyy-MM-ddTHH:mm:ss.",
Expand All @@ -352,4 +353,4 @@
}
}
}
}
}
4 changes: 2 additions & 2 deletions src/GitVersion.App.Tests/ArgumentParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ private static IEnumerable<TestCaseData> OverrideConfigWithSingleOptionTestData(
"mode=ContinuousDelivery",
new GitVersionConfiguration
{
VersioningMode = VersioningMode.ContinuousDelivery
DeploymentMode = DeploymentMode.ContinuousDelivery
}
);
yield return new TestCaseData(
Expand Down Expand Up @@ -567,7 +567,7 @@ private static IEnumerable<TestCaseData> OverrideConfigWithMultipleOptionsTestDa
AssemblyVersioningFormat = "{Major}.{Minor}.{Patch}.{env:CI_JOB_ID ?? 0}",
UpdateBuildNumber = true,
AssemblyVersioningScheme = AssemblyVersioningScheme.MajorMinorPatchTag,
VersioningMode = VersioningMode.ContinuousDelivery,
DeploymentMode = DeploymentMode.ContinuousDelivery,
TagPreReleaseWeight = 4
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public void OverwritesDefaultsWithProvidedConfig()
var developConfiguration = configuration.Branches["develop"];
developConfiguration.Increment.ShouldBe(IncrementStrategy.Major);
developConfiguration.Increment.ShouldNotBe(defaultConfiguration.Branches["develop"].Increment);
developConfiguration.VersioningMode.ShouldBe(VersioningMode.ContinuousDelivery);
developConfiguration.VersioningMode.ShouldNotBe(defaultConfiguration.Branches["develop"].VersioningMode);
developConfiguration.DeploymentMode.ShouldBe(DeploymentMode.ContinuousDelivery);
developConfiguration.DeploymentMode.ShouldNotBe(defaultConfiguration.Branches["develop"].DeploymentMode);
developConfiguration.Label.ShouldBe("dev");
}

Expand Down
6 changes: 3 additions & 3 deletions src/GitVersion.Configuration/BranchConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ namespace GitVersion.Configuration;
internal record BranchConfiguration : IBranchConfiguration
{
[JsonPropertyName("mode")]
[JsonPropertyDescription("The versioning mode for this branch. Can be 'ContinuousDelivery', 'ContinuousDeployment', 'Mainline'.")]
public VersioningMode? VersioningMode { get; internal set; }
[JsonPropertyDescription("The deployment mode for this branch. Can be 'ManualDeployment', 'ContinuousDelivery', 'ContinuousDeployment'.")]
public DeploymentMode? DeploymentMode { get; internal set; }

[JsonPropertyName("label")]
[JsonPropertyDescription("The label to use for this branch. Use the value {BranchName} or similar as a placeholder to insert a named capture group from RegularExpression (fx. the branch name).")]
Expand Down Expand Up @@ -85,7 +85,7 @@ public virtual IBranchConfiguration Inherit(IBranchConfiguration configuration)
return new BranchConfiguration(this)
{
Increment = Increment == IncrementStrategy.Inherit ? configuration.Increment : Increment,
VersioningMode = VersioningMode ?? configuration.VersioningMode,
DeploymentMode = DeploymentMode ?? configuration.DeploymentMode,
Label = Label ?? configuration.Label,
PreventIncrementOfMergedBranchVersion = PreventIncrementOfMergedBranchVersion
?? configuration.PreventIncrementOfMergedBranchVersion,
Expand Down
10 changes: 5 additions & 5 deletions src/GitVersion.Configuration/BranchConfigurationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ internal class BranchConfigurationBuilder
{
public static BranchConfigurationBuilder New => new();

private VersioningMode? versioningMode;
private DeploymentMode? deploymentMode;
private string? label;
private IncrementStrategy increment;
private bool? preventIncrementOfMergedBranchVersion;
Expand All @@ -26,9 +26,9 @@ private BranchConfigurationBuilder()
{
}

public virtual BranchConfigurationBuilder WithVersioningMode(VersioningMode? value)
public virtual BranchConfigurationBuilder WithDeploymentMode(DeploymentMode? value)
{
this.versioningMode = value;
this.deploymentMode = value;
return this;
}

Expand Down Expand Up @@ -130,7 +130,7 @@ public virtual BranchConfigurationBuilder WithPreReleaseWeight(int? value)

public virtual BranchConfigurationBuilder WithConfiguration(IBranchConfiguration value)
{
WithVersioningMode(value.VersioningMode);
WithDeploymentMode(value.DeploymentMode);
WithLabel(value.Label);
WithIncrement(value.Increment);
WithPreventIncrementOfMergedBranchVersion(value.PreventIncrementOfMergedBranchVersion);
Expand All @@ -150,7 +150,7 @@ public virtual BranchConfigurationBuilder WithConfiguration(IBranchConfiguration

public IBranchConfiguration Build() => new BranchConfiguration
{
VersioningMode = versioningMode,
DeploymentMode = deploymentMode,
Label = label,
Increment = increment,
RegularExpression = regularExpression,
Expand Down
8 changes: 4 additions & 4 deletions src/GitVersion.Configuration/ConfigurationBuilderBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ internal abstract class ConfigurationBuilderBase<TConfigurationBuilder> : IConfi
private Dictionary<string, string> mergeMessageFormats = new();
private readonly List<IReadOnlyDictionary<object, object?>> overrides = new();
private readonly Dictionary<string, BranchConfigurationBuilder> branchConfigurationBuilders = new();
private VersioningMode? versioningMode;
private DeploymentMode? versioningMode;
private string? label;
private IncrementStrategy increment = IncrementStrategy.Inherit;
private bool? preventIncrementOfMergedBranchVersion;
Expand Down Expand Up @@ -224,7 +224,7 @@ public virtual TConfigurationBuilder WithBranch(string value, Action<BranchConfi
return (TConfigurationBuilder)this;
}

public virtual TConfigurationBuilder WithVersioningMode(VersioningMode? value)
public virtual TConfigurationBuilder WithDeploymentMode(DeploymentMode? value)
{
this.versioningMode = value;
return (TConfigurationBuilder)this;
Expand Down Expand Up @@ -326,7 +326,7 @@ public virtual TConfigurationBuilder WithConfiguration(IGitVersionConfiguration
{
WithBranch(name).WithConfiguration(branchConfiguration);
}
WithVersioningMode(value.VersioningMode);
WithDeploymentMode(value.DeploymentMode);
WithLabel(value.Label);
WithIncrement(value.Increment);
WithPreventIncrementOfMergedBranchVersion(value.PreventIncrementOfMergedBranchVersion);
Expand Down Expand Up @@ -379,7 +379,7 @@ public virtual IGitVersionConfiguration Build()
SemanticVersionFormat = this.semanticVersionFormat,
Branches = branches,
MergeMessageFormats = this.mergeMessageFormats,
VersioningMode = this.versioningMode,
DeploymentMode = this.versioningMode,
Label = this.label,
Increment = this.increment,
RegularExpression = this.regularExpression,
Expand Down
2 changes: 1 addition & 1 deletion src/GitVersion.Configuration/ConfigurationFileLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ bool HasConfigurationFileAt(string fileName, out string? configFile)
private static void VerifyReadConfig(IGitVersionConfiguration configuration)
{
// Verify no branches are set to TrunkBased mode
if (configuration.Branches.Any(b => b.Value.VersioningMode == VersioningMode.TrunkBased))
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

Expand Down
12 changes: 6 additions & 6 deletions src/GitVersion.Configuration/GitFlowConfigurationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ private GitFlowConfigurationBuilder()
VersionInBranchPattern = ConfigurationConstants.DefaultVersionInBranchPattern,
TagPreReleaseWeight = ConfigurationConstants.DefaultTagPreReleaseWeight,
UpdateBuildNumber = ConfigurationConstants.DefaultUpdateBuildNumber,
VersioningMode = VersioningMode.ContinuousDelivery,
DeploymentMode = DeploymentMode.ContinuousDelivery,
RegularExpression = string.Empty,
Label = ConfigurationConstants.BranchNamePlaceholder,
Increment = IncrementStrategy.Inherit,
Expand Down Expand Up @@ -70,7 +70,7 @@ private GitFlowConfigurationBuilder()
WithBranch(ReleaseBranch.Name).WithConfiguration(new BranchConfiguration
{
Increment = IncrementStrategy.None,
VersioningMode = VersioningMode.ManualDeployment,
DeploymentMode = DeploymentMode.ManualDeployment,
RegularExpression = ReleaseBranch.RegexPattern,
SourceBranches =
[
Expand All @@ -92,7 +92,7 @@ private GitFlowConfigurationBuilder()
{
Increment = IncrementStrategy.Inherit,
RegularExpression = FeatureBranch.RegexPattern,
VersioningMode = VersioningMode.ManualDeployment,
DeploymentMode = DeploymentMode.ManualDeployment,
SourceBranches =
[
this.DevelopBranch.Name,
Expand All @@ -110,7 +110,7 @@ private GitFlowConfigurationBuilder()
{
Increment = IncrementStrategy.Inherit,
RegularExpression = PullRequestBranch.RegexPattern,
VersioningMode = VersioningMode.ContinuousDelivery,
DeploymentMode = DeploymentMode.ContinuousDelivery,
SourceBranches =
[
this.DevelopBranch.Name,
Expand All @@ -129,7 +129,7 @@ private GitFlowConfigurationBuilder()
{
Increment = IncrementStrategy.Inherit,
RegularExpression = HotfixBranch.RegexPattern,
VersioningMode = VersioningMode.ManualDeployment,
DeploymentMode = DeploymentMode.ManualDeployment,
SourceBranches =
[
this.ReleaseBranch.Name,
Expand Down Expand Up @@ -160,7 +160,7 @@ private GitFlowConfigurationBuilder()
{
RegularExpression = UnknownBranch.RegexPattern,
Label = ConfigurationConstants.BranchNamePlaceholder,
VersioningMode = VersioningMode.ManualDeployment,
DeploymentMode = DeploymentMode.ManualDeployment,
Increment = IncrementStrategy.Inherit,
SourceBranches =
[
Expand Down
10 changes: 5 additions & 5 deletions src/GitVersion.Configuration/GitHubFlowConfigurationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ private GitHubFlowConfigurationBuilder()
VersionInBranchPattern = ConfigurationConstants.DefaultVersionInBranchPattern,
TagPreReleaseWeight = ConfigurationConstants.DefaultTagPreReleaseWeight,
UpdateBuildNumber = ConfigurationConstants.DefaultUpdateBuildNumber,
VersioningMode = VersioningMode.ContinuousDelivery,
DeploymentMode = DeploymentMode.ContinuousDelivery,
RegularExpression = string.Empty,
Label = ConfigurationConstants.BranchNamePlaceholder,
Increment = IncrementStrategy.Inherit,
Expand Down Expand Up @@ -53,7 +53,7 @@ private GitHubFlowConfigurationBuilder()
{
Increment = IncrementStrategy.None,
RegularExpression = ReleaseBranch.RegexPattern,
VersioningMode = VersioningMode.ManualDeployment,
DeploymentMode = DeploymentMode.ManualDeployment,
SourceBranches =
[
this.MainBranch.Name,
Expand All @@ -72,7 +72,7 @@ private GitHubFlowConfigurationBuilder()
{
Increment = IncrementStrategy.Inherit,
RegularExpression = FeatureBranch.RegexPattern,
VersioningMode = VersioningMode.ManualDeployment,
DeploymentMode = DeploymentMode.ManualDeployment,
SourceBranches =
[
this.MainBranch.Name,
Expand All @@ -87,7 +87,7 @@ private GitHubFlowConfigurationBuilder()
{
Increment = IncrementStrategy.Inherit,
RegularExpression = PullRequestBranch.RegexPattern,
VersioningMode = VersioningMode.ContinuousDelivery,
DeploymentMode = DeploymentMode.ContinuousDelivery,
SourceBranches =
[
this.MainBranch.Name,
Expand All @@ -103,7 +103,7 @@ private GitHubFlowConfigurationBuilder()
{
RegularExpression = UnknownBranch.RegexPattern,
Label = ConfigurationConstants.BranchNamePlaceholder,
VersioningMode = VersioningMode.ManualDeployment,
DeploymentMode = DeploymentMode.ManualDeployment,
Increment = IncrementStrategy.Inherit,
SourceBranches =
[
Expand Down
2 changes: 1 addition & 1 deletion src/GitVersion.Configuration/Init/EditConfigStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected override string GetPrompt(ConfigurationBuilder configurationBuilder, s

3) Set next version number
4) Branch specific configuration
5) Branch Increment mode (per commit/after tag) (Current: {configuration.VersioningMode ?? VersioningMode.ContinuousDeployment})
5) Branch Increment mode (per commit/after tag) (Current: {configuration.DeploymentMode ?? DeploymentMode.ContinuousDeployment})
6) Assembly versioning scheme (Current: {configuration.AssemblyVersioningScheme})
7) Setup build scripts";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected override string GetPrompt(ConfigurationBuilder configurationBuilder, s

0) Go Back
1) Branch Pr-release tag (Current: {branchConfiguration.Label})
2) Branch Increment mode (per commit/after tag) (Current: {branchConfiguration.VersioningMode})";
2) Branch Increment mode (per commit/after tag) (Current: {branchConfiguration.DeploymentMode})";
}

protected override string DefaultResult => "0";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ protected override StepResult HandleResult(
switch (result)
{
case "1":
configurationBuilder.WithVersioningMode(VersioningMode.ContinuousDelivery);
configurationBuilder.WithDeploymentMode(DeploymentMode.ContinuousDelivery);
steps.Enqueue(this.returnToStep);
return StepResult.Ok();
case "2":
configurationBuilder.WithVersioningMode(VersioningMode.ContinuousDeployment);
configurationBuilder.WithDeploymentMode(DeploymentMode.ContinuousDeployment);
steps.Enqueue(this.returnToStep);
return StepResult.Ok();
case "3":
configurationBuilder.WithVersioningMode(VersioningMode.TrunkBased);
configurationBuilder.WithDeploymentMode(DeploymentMode.TrunkBased);
steps.Enqueue(this.returnToStep);
return StepResult.Ok();
case "0":
Expand Down
Loading