From fec1343f241d7038878ce88ee184e430a8c25379 Mon Sep 17 00:00:00 2001 From: Artur Stolear Date: Thu, 30 Jul 2026 19:32:16 +0200 Subject: [PATCH 1/2] feat!: rename pre-release output variables --- build/common/Addins/GitVersion/GitVersion.cs | 18 ++++----- build/common/Utilities/Models.cs | 10 ++--- schemas/7.0/GitVersion.configuration.json | 4 +- schemas/7.0/GitVersion.json | 24 ++++++------ .../ArgumentParserTests.cs | 4 +- .../LegacyArgumentParserTests.cs | 4 +- .../ConfigurationProviderTests.cs | 8 ++-- .../BranchConfiguration.cs | 2 +- .../Core/GitVersionExecutorTests.cs | 8 ++-- .../Helpers/TestableGitVersionVariables.cs | 6 +-- .../JsonVersionBuilderTests.Json.approved.txt | 8 ++-- ...sDeliveryModeForFeatureBranch.approved.txt | 6 +-- ...hWithCustomAssemblyInfoFormat.approved.txt | 6 +-- ...uousDeliveryModeForPreRelease.approved.txt | 8 ++-- ...ntinuousDeliveryModeForStable.approved.txt | 6 +-- ...deForMainBranchWithEmptyLabel.approved.txt | 8 ++-- ...usDeploymentModeForPreRelease.approved.txt | 8 ++-- ...inuousDeploymentModeForStable.approved.txt | 8 ++-- ...ableWhenCurrentCommitIsTagged.approved.txt | 6 +-- .../VariableProviderTests.cs | 39 ++++++++++++++++++- .../OutputVariables/GitVersionVariables.cs | 18 ++++----- src/GitVersion.Core/PublicAPI.Shipped.txt | 12 +++--- src/GitVersion.Core/PublicAPI.Unshipped.txt | 4 +- .../SemanticVersionFormatValues.cs | 20 +++++----- .../VersionCalculation/VariableProvider.cs | 6 +-- .../Tasks/GetVersionTaskTests.cs | 10 +++++ src/GitVersion.MsBuild/PublicAPI.Shipped.txt | 8 ++-- src/GitVersion.MsBuild/Tasks/GetVersion.cs | 8 ++-- .../msbuild/tools/GitVersion.MsBuild.targets | 14 +++---- ...ileTests.UpdateWixVersionFile.approved.txt | 4 +- ...sionFileWhenFileAlreadyExists.approved.txt | 4 +- ...neratorTests.ShouldCreateFile.approved.txt | 8 ++-- ...rlyOutputNamespaceDeclaration.approved.txt | 8 ++-- ...neratorTests.ShouldCreateFile.approved.txt | 8 ++-- ...rlyOutputNamespaceDeclaration.approved.txt | 8 ++-- ...neratorTests.ShouldCreateFile.approved.txt | 8 ++-- ...rlyOutputNamespaceDeclaration.approved.txt | 8 ++-- .../Output/FormatArgumentTests.cs | 15 ++++--- .../Serializer/VersionVariablesJsonModel.cs | 18 ++++----- 39 files changed, 216 insertions(+), 164 deletions(-) diff --git a/build/common/Addins/GitVersion/GitVersion.cs b/build/common/Addins/GitVersion/GitVersion.cs index c58a74bf31..defd84a494 100644 --- a/build/common/Addins/GitVersion/GitVersion.cs +++ b/build/common/Addins/GitVersion/GitVersion.cs @@ -77,14 +77,14 @@ public sealed class GitVersion public int? Patch { get; set; } /// - /// Gets or sets the pre-release label. The pre-release label is the name of the pre-release. + /// Gets or sets the pre-release label name without the numeric identifier. /// - public string? PreReleaseLabel { get; set; } + public string? PreReleaseLabelName { get; set; } /// - /// Gets or sets the pre-release label with dash. The pre-release label prefixed with a dash. + /// Gets or sets the pre-release label name prefixed with a dash. /// - public string? PreReleaseLabelWithDash { get; set; } + public string? PreReleaseLabelNameWithDash { get; set; } /// /// Gets or sets the pre-release number. The pre-release number is the number of commits since the last version bump. @@ -92,17 +92,17 @@ public sealed class GitVersion public int? PreReleaseNumber { get; set; } /// - /// Gets or sets the pre-release tag. The pre-release tag is the pre-release label suffixed by the PreReleaseNumber. + /// Gets or sets the full pre-release label, including the PreReleaseNumber when present. /// - public string? PreReleaseTag { get; set; } + public string? PreReleaseLabel { get; set; } /// - /// Gets or sets the pre-release tag with dash. The pre-release tag prefixed with a dash. + /// Gets or sets the pre-release label prefixed with a dash. /// - public string? PreReleaseTagWithDash { get; set; } + public string? PreReleaseLabelWithDash { get; set; } /// - /// Gets or sets the Semantic Version. The semantic version number, including PreReleaseTagWithDash for pre-release version numbers. + /// Gets or sets the Semantic Version. The semantic version number, including PreReleaseLabelWithDash for pre-release version numbers. /// public string? SemVer { get; set; } diff --git a/build/common/Utilities/Models.cs b/build/common/Utilities/Models.cs index 48588ede14..642a07ec32 100644 --- a/build/common/Utilities/Models.cs +++ b/build/common/Utilities/Models.cs @@ -24,13 +24,13 @@ public static BuildVersion Calculate(GitVersion gitVersion) var nugetVersion = gitVersion.SemVer; var chocolateyVersion = gitVersion.MajorMinorPatch; - if (!string.IsNullOrWhiteSpace(gitVersion.PreReleaseTag)) + if (!string.IsNullOrWhiteSpace(gitVersion.PreReleaseLabel)) { - // Chocolatey does not support pre-release tags with dots, so we replace them with dashes - // if the pre-release tag is a number, we add a "a" prefix to the pre-release tag + // Chocolatey does not support pre-release labels with dots, so we replace them with dashes + // if the pre-release label name is a number, we add an "a" prefix to the pre-release label // the trick should be removed when Chocolatey supports semver 2.0 - var prefix = int.TryParse(gitVersion.PreReleaseLabel, out _) ? "a" : string.Empty; - chocolateyVersion += $"-{prefix}{gitVersion.PreReleaseTag?.Replace(".", "-")}"; + var prefix = int.TryParse(gitVersion.PreReleaseLabelName, out _) ? "a" : string.Empty; + chocolateyVersion += $"-{prefix}{gitVersion.PreReleaseLabel?.Replace(".", "-")}"; } if (gitVersion.BuildMetaData is not null) diff --git a/schemas/7.0/GitVersion.configuration.json b/schemas/7.0/GitVersion.configuration.json index 3a711879a0..dc95b66a8b 100644 --- a/schemas/7.0/GitVersion.configuration.json +++ b/schemas/7.0/GitVersion.configuration.json @@ -112,7 +112,7 @@ ] }, "pre-release-weight": { - "description": "Provides a way to translate the PreReleaseLabel to a number.", + "description": "Provides a way to translate the PreReleaseLabelName to a number.", "type": [ "null", "integer" @@ -293,7 +293,7 @@ ] }, "pre-release-weight": { - "description": "Provides a way to translate the PreReleaseLabel to a number.", + "description": "Provides a way to translate the PreReleaseLabelName to a number.", "type": [ "null", "integer" diff --git a/schemas/7.0/GitVersion.json b/schemas/7.0/GitVersion.json index de01594a57..3354797c9a 100644 --- a/schemas/7.0/GitVersion.json +++ b/schemas/7.0/GitVersion.json @@ -104,42 +104,42 @@ ] }, "PreReleaseLabel": { - "description": "The pre-release label is the name of the pre-release.", + "description": "The full pre-release label, including the PreReleaseNumber when present.", "type": [ "null", "string" ] }, - "PreReleaseLabelWithDash": { - "description": "The pre-release label prefixed with a dash.", + "PreReleaseLabelName": { + "description": "The name of the pre-release label, without the PreReleaseNumber.", "type": [ "null", "string" ] }, - "PreReleaseNumber": { - "description": "The pre-release number is the number of commits since the last version bump.", + "PreReleaseLabelNameWithDash": { + "description": "The pre-release label name prefixed with a dash.", "type": [ "null", - "integer" + "string" ] }, - "PreReleaseTag": { - "description": "The pre-release tag is the pre-release label suffixed by the PreReleaseNumber.", + "PreReleaseLabelWithDash": { + "description": "The pre-release label prefixed with a dash.", "type": [ "null", "string" ] }, - "PreReleaseTagWithDash": { - "description": "The pre-release tag prefixed with a dash.", + "PreReleaseNumber": { + "description": "The pre-release number is the number of commits since the last version bump.", "type": [ "null", - "string" + "integer" ] }, "SemVer": { - "description": "The semantic version number, including PreReleaseTagWithDash for pre-release version numbers.", + "description": "The semantic version number, including PreReleaseLabelWithDash for pre-release version numbers.", "type": [ "null", "string" diff --git a/src/GitVersion.App.Tests/ArgumentParserTests.cs b/src/GitVersion.App.Tests/ArgumentParserTests.cs index 20fc2e3006..600063e961 100644 --- a/src/GitVersion.App.Tests/ArgumentParserTests.cs +++ b/src/GitVersion.App.Tests/ArgumentParserTests.cs @@ -450,10 +450,10 @@ private static IEnumerable OverrideConfigWithSingleOptionTestData( } ); yield return new TestCaseData( - "custom-version-format=\"{Major}.{Minor}.{Patch}{PreReleaseLabel:l}{PreReleaseNumber}\"", + "custom-version-format=\"{Major}.{Minor}.{Patch}{PreReleaseLabelName:l}{PreReleaseNumber}\"", new GitVersionConfiguration { - CustomVersionFormat = "{Major}.{Minor}.{Patch}{PreReleaseLabel:l}{PreReleaseNumber}" + CustomVersionFormat = "{Major}.{Minor}.{Patch}{PreReleaseLabelName:l}{PreReleaseNumber}" } ); yield return new TestCaseData( diff --git a/src/GitVersion.App.Tests/LegacyArgumentParserTests.cs b/src/GitVersion.App.Tests/LegacyArgumentParserTests.cs index 29da2a80c3..3b974b35b4 100644 --- a/src/GitVersion.App.Tests/LegacyArgumentParserTests.cs +++ b/src/GitVersion.App.Tests/LegacyArgumentParserTests.cs @@ -440,10 +440,10 @@ private static IEnumerable OverrideConfigWithSingleOptionTestData( } ); yield return new TestCaseData( - "custom-version-format=\"{Major}.{Minor}.{Patch}{PreReleaseLabel:l}{PreReleaseNumber}\"", + "custom-version-format=\"{Major}.{Minor}.{Patch}{PreReleaseLabelName:l}{PreReleaseNumber}\"", new GitVersionConfiguration { - CustomVersionFormat = "{Major}.{Minor}.{Patch}{PreReleaseLabel:l}{PreReleaseNumber}" + CustomVersionFormat = "{Major}.{Minor}.{Patch}{PreReleaseLabelName:l}{PreReleaseNumber}" } ); yield return new TestCaseData( diff --git a/src/GitVersion.Configuration.Tests/Configuration/ConfigurationProviderTests.cs b/src/GitVersion.Configuration.Tests/Configuration/ConfigurationProviderTests.cs index 4250f4ff3d..8951d783e7 100644 --- a/src/GitVersion.Configuration.Tests/Configuration/ConfigurationProviderTests.cs +++ b/src/GitVersion.Configuration.Tests/Configuration/ConfigurationProviderTests.cs @@ -245,12 +245,12 @@ public void CanUpdateAssemblyInformationalVersioningSchemeWithFullSemVer() [Test] public void CanReadCustomVersionFormat() { - const string text = "custom-version-format: '{Major}.{Minor}.{Patch}{PreReleaseLabel:l}{PreReleaseNumber}'"; + const string text = "custom-version-format: '{Major}.{Minor}.{Patch}{PreReleaseLabelName:l}{PreReleaseNumber}'"; using var _ = this.fileSystem.SetupConfigFile(path: this.repoPath, text: text); var configuration = this.configurationProvider.ProvideForDirectory(this.repoPath); - configuration.CustomVersionFormat.ShouldBe("{Major}.{Minor}.{Patch}{PreReleaseLabel:l}{PreReleaseNumber}"); + configuration.CustomVersionFormat.ShouldBe("{Major}.{Minor}.{Patch}{PreReleaseLabelName:l}{PreReleaseNumber}"); } [Test] @@ -260,14 +260,14 @@ public void CanReadBranchSpecificCustomVersionFormat() custom-version-format: '{SemVer}' branches: feature: - custom-version-format: '{Major}.{Minor}.{Patch}{PreReleaseLabel:l}{PreReleaseNumber}' + custom-version-format: '{Major}.{Minor}.{Patch}{PreReleaseLabelName:l}{PreReleaseNumber}' """; using var _ = this.fileSystem.SetupConfigFile(path: this.repoPath, text: text); var configuration = this.configurationProvider.ProvideForDirectory(this.repoPath); configuration.CustomVersionFormat.ShouldBe("{SemVer}"); - configuration.Branches["feature"].CustomVersionFormat.ShouldBe("{Major}.{Minor}.{Patch}{PreReleaseLabel:l}{PreReleaseNumber}"); + configuration.Branches["feature"].CustomVersionFormat.ShouldBe("{Major}.{Minor}.{Patch}{PreReleaseLabelName:l}{PreReleaseNumber}"); } [Test] diff --git a/src/GitVersion.Configuration/BranchConfiguration.cs b/src/GitVersion.Configuration/BranchConfiguration.cs index 2adeab1c15..5b408bd999 100644 --- a/src/GitVersion.Configuration/BranchConfiguration.cs +++ b/src/GitVersion.Configuration/BranchConfiguration.cs @@ -76,7 +76,7 @@ internal record BranchConfiguration : IBranchConfiguration public bool? IsMainBranch { get; set; } [JsonPropertyName("pre-release-weight")] - [JsonPropertyDescription("Provides a way to translate the PreReleaseLabel to a number.")] + [JsonPropertyDescription("Provides a way to translate the PreReleaseLabelName to a number.")] public int? PreReleaseWeight { get; set; } public virtual IBranchConfiguration Inherit(IBranchConfiguration configuration) diff --git a/src/GitVersion.Core.Tests/Core/GitVersionExecutorTests.cs b/src/GitVersion.Core.Tests/Core/GitVersionExecutorTests.cs index e028b7f4dc..f644a826b7 100644 --- a/src/GitVersion.Core.Tests/Core/GitVersionExecutorTests.cs +++ b/src/GitVersion.Core.Tests/Core/GitVersionExecutorTests.cs @@ -36,11 +36,11 @@ public class GitVersionExecutorTests : TestBase "MajorMinorPatch": "4.10.3", "Minor": 10, "Patch": 3, - "PreReleaseLabel": "test", - "PreReleaseLabelWithDash": "-test", + "PreReleaseLabel": "test.19", + "PreReleaseLabelName": "test", + "PreReleaseLabelNameWithDash": "-test", + "PreReleaseLabelWithDash": "-test.19", "PreReleaseNumber": 19, - "PreReleaseTag": "test.19", - "PreReleaseTagWithDash": "-test.19", "SemVer": "4.10.3-test.19", "Sha": "dd2a29aff0c948e1bdf3dabbe13e1576e70d5f9f", "ShortSha": "dd2a29af", diff --git a/src/GitVersion.Core.Tests/Helpers/TestableGitVersionVariables.cs b/src/GitVersion.Core.Tests/Helpers/TestableGitVersionVariables.cs index bf4bc0807a..6db356a430 100644 --- a/src/GitVersion.Core.Tests/Helpers/TestableGitVersionVariables.cs +++ b/src/GitVersion.Core.Tests/Helpers/TestableGitVersionVariables.cs @@ -17,11 +17,11 @@ internal record TestableGitVersionVariables() : GitVersionVariables( MajorMinorPatch: "", Minor: "", Patch: "", + PreReleaseLabelName: "", + PreReleaseLabelNameWithDash: "", + PreReleaseNumber: "", PreReleaseLabel: "", PreReleaseLabelWithDash: "", - PreReleaseNumber: "", - PreReleaseTag: "", - PreReleaseTagWithDash: "", SemVer: "", Sha: "", ShortSha: "", diff --git a/src/GitVersion.Core.Tests/VersionCalculation/Approved/JsonVersionBuilderTests.Json.approved.txt b/src/GitVersion.Core.Tests/VersionCalculation/Approved/JsonVersionBuilderTests.Json.approved.txt index 96c885d7c0..5630e120f4 100644 --- a/src/GitVersion.Core.Tests/VersionCalculation/Approved/JsonVersionBuilderTests.Json.approved.txt +++ b/src/GitVersion.Core.Tests/VersionCalculation/Approved/JsonVersionBuilderTests.Json.approved.txt @@ -13,11 +13,11 @@ "MajorMinorPatch": "1.2.0", "Minor": 2, "Patch": 0, - "PreReleaseLabel": "unstable", - "PreReleaseLabelWithDash": "-unstable", + "PreReleaseLabelName": "unstable", + "PreReleaseLabelNameWithDash": "-unstable", "PreReleaseNumber": 4, - "PreReleaseTag": "unstable.4", - "PreReleaseTagWithDash": "-unstable.4", + "PreReleaseLabel": "unstable.4", + "PreReleaseLabelWithDash": "-unstable.4", "SemVer": "1.2.0-unstable.4", "Sha": "commitSha", "ShortSha": "commitShortSha", diff --git a/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForFeatureBranch.approved.txt b/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForFeatureBranch.approved.txt index 29cdc2f027..713e3c2f47 100644 --- a/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForFeatureBranch.approved.txt +++ b/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForFeatureBranch.approved.txt @@ -13,11 +13,11 @@ "MajorMinorPatch": "1.2.3", "Minor": 2, "Patch": 3, + "PreReleaseLabelName": "", + "PreReleaseLabelNameWithDash": "", + "PreReleaseNumber": null, "PreReleaseLabel": "", "PreReleaseLabelWithDash": "", - "PreReleaseNumber": null, - "PreReleaseTag": "", - "PreReleaseTagWithDash": "", "SemVer": "1.2.3", "Sha": "commitSha", "ShortSha": "commitShortSha", diff --git a/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForFeatureBranchWithCustomAssemblyInfoFormat.approved.txt b/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForFeatureBranchWithCustomAssemblyInfoFormat.approved.txt index 9084e28bca..523467a4e2 100644 --- a/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForFeatureBranchWithCustomAssemblyInfoFormat.approved.txt +++ b/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForFeatureBranchWithCustomAssemblyInfoFormat.approved.txt @@ -13,11 +13,11 @@ "MajorMinorPatch": "1.2.3", "Minor": 2, "Patch": 3, + "PreReleaseLabelName": "", + "PreReleaseLabelNameWithDash": "", + "PreReleaseNumber": null, "PreReleaseLabel": "", "PreReleaseLabelWithDash": "", - "PreReleaseNumber": null, - "PreReleaseTag": "", - "PreReleaseTagWithDash": "", "SemVer": "1.2.3", "Sha": "commitSha", "ShortSha": "commitShortSha", diff --git a/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForPreRelease.approved.txt b/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForPreRelease.approved.txt index ba766a58f8..71e7812f73 100644 --- a/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForPreRelease.approved.txt +++ b/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForPreRelease.approved.txt @@ -13,11 +13,11 @@ "MajorMinorPatch": "1.2.3", "Minor": 2, "Patch": 3, - "PreReleaseLabel": "unstable", - "PreReleaseLabelWithDash": "-unstable", + "PreReleaseLabelName": "unstable", + "PreReleaseLabelNameWithDash": "-unstable", "PreReleaseNumber": 4, - "PreReleaseTag": "unstable.4", - "PreReleaseTagWithDash": "-unstable.4", + "PreReleaseLabel": "unstable.4", + "PreReleaseLabelWithDash": "-unstable.4", "SemVer": "1.2.3-unstable.4", "Sha": "commitSha", "ShortSha": "commitShortSha", diff --git a/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForStable.approved.txt b/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForStable.approved.txt index 866e6964e5..4d006e462e 100644 --- a/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForStable.approved.txt +++ b/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForStable.approved.txt @@ -13,11 +13,11 @@ "MajorMinorPatch": "1.2.3", "Minor": 2, "Patch": 3, + "PreReleaseLabelName": "", + "PreReleaseLabelNameWithDash": "", + "PreReleaseNumber": null, "PreReleaseLabel": "", "PreReleaseLabelWithDash": "", - "PreReleaseNumber": null, - "PreReleaseTag": "", - "PreReleaseTagWithDash": "", "SemVer": "1.2.3", "Sha": "commitSha", "ShortSha": "commitShortSha", diff --git a/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForMainBranchWithEmptyLabel.approved.txt b/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForMainBranchWithEmptyLabel.approved.txt index dd01575e57..de7b7f5f5f 100644 --- a/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForMainBranchWithEmptyLabel.approved.txt +++ b/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForMainBranchWithEmptyLabel.approved.txt @@ -13,11 +13,11 @@ "MajorMinorPatch": "1.2.3", "Minor": 2, "Patch": 3, - "PreReleaseLabel": "", - "PreReleaseLabelWithDash": "", + "PreReleaseLabelName": "", + "PreReleaseLabelNameWithDash": "", "PreReleaseNumber": 9, - "PreReleaseTag": "9", - "PreReleaseTagWithDash": "-9", + "PreReleaseLabel": "9", + "PreReleaseLabelWithDash": "-9", "SemVer": "1.2.3-9", "Sha": "commitSha", "ShortSha": "commitShortSha", diff --git a/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForPreRelease.approved.txt b/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForPreRelease.approved.txt index 86dc279418..931b02b40e 100644 --- a/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForPreRelease.approved.txt +++ b/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForPreRelease.approved.txt @@ -13,11 +13,11 @@ "MajorMinorPatch": "1.2.3", "Minor": 2, "Patch": 3, - "PreReleaseLabel": "unstable", - "PreReleaseLabelWithDash": "-unstable", + "PreReleaseLabelName": "unstable", + "PreReleaseLabelNameWithDash": "-unstable", "PreReleaseNumber": 8, - "PreReleaseTag": "unstable.8", - "PreReleaseTagWithDash": "-unstable.8", + "PreReleaseLabel": "unstable.8", + "PreReleaseLabelWithDash": "-unstable.8", "SemVer": "1.2.3-unstable.8", "Sha": "commitSha", "ShortSha": "commitShortSha", diff --git a/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForStable.approved.txt b/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForStable.approved.txt index b331725960..f08438fa27 100644 --- a/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForStable.approved.txt +++ b/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForStable.approved.txt @@ -13,11 +13,11 @@ "MajorMinorPatch": "1.2.3", "Minor": 2, "Patch": 3, - "PreReleaseLabel": "ci", - "PreReleaseLabelWithDash": "-ci", + "PreReleaseLabelName": "ci", + "PreReleaseLabelNameWithDash": "-ci", "PreReleaseNumber": 5, - "PreReleaseTag": "ci.5", - "PreReleaseTagWithDash": "-ci.5", + "PreReleaseLabel": "ci.5", + "PreReleaseLabelWithDash": "-ci.5", "SemVer": "1.2.3-ci.5", "Sha": "commitSha", "ShortSha": "commitShortSha", diff --git a/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForStableWhenCurrentCommitIsTagged.approved.txt b/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForStableWhenCurrentCommitIsTagged.approved.txt index 608fc16d81..6a373e9406 100644 --- a/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForStableWhenCurrentCommitIsTagged.approved.txt +++ b/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForStableWhenCurrentCommitIsTagged.approved.txt @@ -13,11 +13,11 @@ "MajorMinorPatch": "1.2.3", "Minor": 2, "Patch": 3, + "PreReleaseLabelName": "", + "PreReleaseLabelNameWithDash": "", + "PreReleaseNumber": null, "PreReleaseLabel": "", "PreReleaseLabelWithDash": "", - "PreReleaseNumber": null, - "PreReleaseTag": "", - "PreReleaseTagWithDash": "", "SemVer": "1.2.3", "Sha": "commitSha", "ShortSha": "commitShortSha", diff --git a/src/GitVersion.Core.Tests/VersionCalculation/VariableProviderTests.cs b/src/GitVersion.Core.Tests/VersionCalculation/VariableProviderTests.cs index 499e8359d6..08bcbc8ce0 100644 --- a/src/GitVersion.Core.Tests/VersionCalculation/VariableProviderTests.cs +++ b/src/GitVersion.Core.Tests/VersionCalculation/VariableProviderTests.cs @@ -310,7 +310,7 @@ public void CustomVersionSupportsPep440FormatForIssue2065() BuildMetaData = new() }; var configuration = GitFlowConfigurationBuilder.New - .WithCustomVersionFormat("{Major}.{Minor}.{Patch}{PreReleaseLabel:l}{PreReleaseNumber}") + .WithCustomVersionFormat("{Major}.{Minor}.{Patch}{PreReleaseLabelName:l}{PreReleaseNumber}") .Build(); var effectiveConfiguration = configuration.GetEffectiveConfiguration(); @@ -319,6 +319,43 @@ public void CustomVersionSupportsPep440FormatForIssue2065() variables.CustomVersion.ShouldBe("0.6.3beta10"); } + [TestCase("beta", 99, "beta", "99", "beta.99", "-beta", "-beta.99")] + [TestCase("", 99, "", "99", "99", "", "-99")] + [TestCase(null, null, "", "", "", "", "")] + public void ProvidesUnambiguousPreReleaseVariables( + string? labelName, long? number, + string expectedLabelName, string expectedNumber, string expectedLabel, + string expectedLabelNameWithDash, string expectedLabelWithDash) + { + var semanticVersion = new SemanticVersion + { + Major = 1, + Minor = 2, + Patch = 3, + PreReleaseTag = labelName is null && number is null + ? SemanticVersionPreReleaseTag.Empty + : new(labelName ?? string.Empty, number, true), + BuildMetaData = new() + }; + var configuration = GitFlowConfigurationBuilder.New.Build(); + var effectiveConfiguration = configuration.GetEffectiveConfiguration(); + + var variables = this.variableProvider.GetVariablesFor(semanticVersion, configuration, effectiveConfiguration); + + variables.PreReleaseLabelName.ShouldBe(expectedLabelName); + variables.PreReleaseLabelNameWithDash.ShouldBe(expectedLabelNameWithDash); + variables.PreReleaseNumber.ShouldBe(expectedNumber); + variables.PreReleaseLabel.ShouldBe(expectedLabel); + variables.PreReleaseLabelWithDash.ShouldBe(expectedLabelWithDash); + + var roundTrippedVariables = variables.ToJson().ToGitVersionVariables(); + roundTrippedVariables.PreReleaseLabelName.ShouldBe(expectedLabelName); + roundTrippedVariables.PreReleaseLabelNameWithDash.ShouldBe(expectedLabelNameWithDash); + roundTrippedVariables.PreReleaseNumber.ShouldBe(expectedNumber); + roundTrippedVariables.PreReleaseLabel.ShouldBe(expectedLabel); + roundTrippedVariables.PreReleaseLabelWithDash.ShouldBe(expectedLabelWithDash); + } + [Test] public void CustomVersionFormatCanBeConfiguredPerBranch() { diff --git a/src/GitVersion.Core/OutputVariables/GitVersionVariables.cs b/src/GitVersion.Core/OutputVariables/GitVersionVariables.cs index 0a039690ac..cc17949983 100644 --- a/src/GitVersion.Core/OutputVariables/GitVersionVariables.cs +++ b/src/GitVersion.Core/OutputVariables/GitVersionVariables.cs @@ -16,11 +16,11 @@ public record GitVersionVariables( string MajorMinorPatch, string Minor, string Patch, + string? PreReleaseLabelName, + string? PreReleaseLabelNameWithDash, + string? PreReleaseNumber, string? PreReleaseLabel, string? PreReleaseLabelWithDash, - string? PreReleaseNumber, - string? PreReleaseTag, - string? PreReleaseTagWithDash, string SemVer, string? Sha, string? ShortSha, @@ -48,11 +48,11 @@ string WeightedPreReleaseNumber nameof(MajorMinorPatch), nameof(Minor), nameof(Patch), + nameof(PreReleaseLabelName), + nameof(PreReleaseLabelNameWithDash), + nameof(PreReleaseNumber), nameof(PreReleaseLabel), nameof(PreReleaseLabelWithDash), - nameof(PreReleaseNumber), - nameof(PreReleaseTag), - nameof(PreReleaseTagWithDash), nameof(SemVer), nameof(Sha), nameof(ShortSha), @@ -80,11 +80,11 @@ string WeightedPreReleaseNumber { nameof(MajorMinorPatch), MajorMinorPatch }, { nameof(Minor), Minor }, { nameof(Patch), Patch }, + { nameof(PreReleaseLabelName), PreReleaseLabelName }, + { nameof(PreReleaseLabelNameWithDash), PreReleaseLabelNameWithDash }, + { nameof(PreReleaseNumber), PreReleaseNumber }, { nameof(PreReleaseLabel), PreReleaseLabel }, { nameof(PreReleaseLabelWithDash), PreReleaseLabelWithDash }, - { nameof(PreReleaseNumber), PreReleaseNumber }, - { nameof(PreReleaseTag), PreReleaseTag }, - { nameof(PreReleaseTagWithDash), PreReleaseTagWithDash }, { nameof(SemVer), SemVer }, { nameof(Sha), Sha }, { nameof(ShortSha), ShortSha }, diff --git a/src/GitVersion.Core/PublicAPI.Shipped.txt b/src/GitVersion.Core/PublicAPI.Shipped.txt index 9c2694cb79..aeebd3a90e 100644 --- a/src/GitVersion.Core/PublicAPI.Shipped.txt +++ b/src/GitVersion.Core/PublicAPI.Shipped.txt @@ -456,14 +456,14 @@ GitVersion.OutputVariables.GitVersionVariables.Patch.get -> string! GitVersion.OutputVariables.GitVersionVariables.Patch.init -> void GitVersion.OutputVariables.GitVersionVariables.PreReleaseLabel.get -> string? GitVersion.OutputVariables.GitVersionVariables.PreReleaseLabel.init -> void +GitVersion.OutputVariables.GitVersionVariables.PreReleaseLabelName.get -> string? +GitVersion.OutputVariables.GitVersionVariables.PreReleaseLabelName.init -> void +GitVersion.OutputVariables.GitVersionVariables.PreReleaseLabelNameWithDash.get -> string? +GitVersion.OutputVariables.GitVersionVariables.PreReleaseLabelNameWithDash.init -> void GitVersion.OutputVariables.GitVersionVariables.PreReleaseLabelWithDash.get -> string? GitVersion.OutputVariables.GitVersionVariables.PreReleaseLabelWithDash.init -> void GitVersion.OutputVariables.GitVersionVariables.PreReleaseNumber.get -> string? GitVersion.OutputVariables.GitVersionVariables.PreReleaseNumber.init -> void -GitVersion.OutputVariables.GitVersionVariables.PreReleaseTag.get -> string? -GitVersion.OutputVariables.GitVersionVariables.PreReleaseTag.init -> void -GitVersion.OutputVariables.GitVersionVariables.PreReleaseTagWithDash.get -> string? -GitVersion.OutputVariables.GitVersionVariables.PreReleaseTagWithDash.init -> void GitVersion.OutputVariables.GitVersionVariables.SemVer.get -> string! GitVersion.OutputVariables.GitVersionVariables.SemVer.init -> void GitVersion.OutputVariables.GitVersionVariables.Sha.get -> string? @@ -580,10 +580,10 @@ GitVersion.SemanticVersionFormatValues.MajorMinorPatch.get -> string! GitVersion.SemanticVersionFormatValues.Minor.get -> string! GitVersion.SemanticVersionFormatValues.Patch.get -> string! GitVersion.SemanticVersionFormatValues.PreReleaseLabel.get -> string! +GitVersion.SemanticVersionFormatValues.PreReleaseLabelName.get -> string! +GitVersion.SemanticVersionFormatValues.PreReleaseLabelNameWithDash.get -> string! GitVersion.SemanticVersionFormatValues.PreReleaseLabelWithDash.get -> string! GitVersion.SemanticVersionFormatValues.PreReleaseNumber.get -> string! -GitVersion.SemanticVersionFormatValues.PreReleaseTag.get -> string! -GitVersion.SemanticVersionFormatValues.PreReleaseTagWithDash.get -> string! GitVersion.SemanticVersionFormatValues.SemanticVersionFormatValues(GitVersion.SemanticVersion! semver, GitVersion.Configuration.IGitVersionConfiguration! configuration, int preReleaseWeight) -> void GitVersion.SemanticVersionFormatValues.SemVer.get -> string! GitVersion.SemanticVersionFormatValues.Sha.get -> string? diff --git a/src/GitVersion.Core/PublicAPI.Unshipped.txt b/src/GitVersion.Core/PublicAPI.Unshipped.txt index d05cb64228..ac978cb3f5 100644 --- a/src/GitVersion.Core/PublicAPI.Unshipped.txt +++ b/src/GitVersion.Core/PublicAPI.Unshipped.txt @@ -5,8 +5,8 @@ GitVersion.VersionCalculation.IVariableProvider.GetVariablesFor(GitVersion.Seman *REMOVED*GitVersion.VersionCalculation.IVariableProvider.GetVariablesFor(GitVersion.SemanticVersion! semanticVersion, GitVersion.Configuration.IGitVersionConfiguration! configuration, int preReleaseWeight) -> GitVersion.OutputVariables.GitVersionVariables! GitVersion.OutputVariables.GitVersionVariables.CustomVersion.get -> string? GitVersion.OutputVariables.GitVersionVariables.CustomVersion.init -> void -GitVersion.OutputVariables.GitVersionVariables.Deconstruct(out string? AssemblySemFileVer, out string? AssemblySemVer, out string? BranchName, out string? BuildMetaData, out string? CommitDate, out string? CustomVersion, out string? EscapedBranchName, out string? FullBuildMetaData, out string! FullSemVer, out string? InformationalVersion, out string! Major, out string! MajorMinorPatch, out string! Minor, out string! Patch, out string? PreReleaseLabel, out string? PreReleaseLabelWithDash, out string? PreReleaseNumber, out string? PreReleaseTag, out string? PreReleaseTagWithDash, out string! SemVer, out string? Sha, out string? ShortSha, out string? UncommittedChanges, out string? VersionSourceDistance, out string? VersionSourceIncrement, out string? VersionSourceSemVer, out string? VersionSourceSha, out string! WeightedPreReleaseNumber) -> void -GitVersion.OutputVariables.GitVersionVariables.GitVersionVariables(string? AssemblySemFileVer, string? AssemblySemVer, string? BranchName, string? BuildMetaData, string? CommitDate, string? CustomVersion, string? EscapedBranchName, string? FullBuildMetaData, string! FullSemVer, string? InformationalVersion, string! Major, string! MajorMinorPatch, string! Minor, string! Patch, string? PreReleaseLabel, string? PreReleaseLabelWithDash, string? PreReleaseNumber, string? PreReleaseTag, string? PreReleaseTagWithDash, string! SemVer, string? Sha, string? ShortSha, string? UncommittedChanges, string? VersionSourceDistance, string? VersionSourceIncrement, string? VersionSourceSemVer, string? VersionSourceSha, string! WeightedPreReleaseNumber) -> void +GitVersion.OutputVariables.GitVersionVariables.Deconstruct(out string? AssemblySemFileVer, out string? AssemblySemVer, out string? BranchName, out string? BuildMetaData, out string? CommitDate, out string? CustomVersion, out string? EscapedBranchName, out string? FullBuildMetaData, out string! FullSemVer, out string? InformationalVersion, out string! Major, out string! MajorMinorPatch, out string! Minor, out string! Patch, out string? PreReleaseLabelName, out string? PreReleaseLabelNameWithDash, out string? PreReleaseNumber, out string? PreReleaseLabel, out string? PreReleaseLabelWithDash, out string! SemVer, out string? Sha, out string? ShortSha, out string? UncommittedChanges, out string? VersionSourceDistance, out string? VersionSourceIncrement, out string? VersionSourceSemVer, out string? VersionSourceSha, out string! WeightedPreReleaseNumber) -> void +GitVersion.OutputVariables.GitVersionVariables.GitVersionVariables(string? AssemblySemFileVer, string? AssemblySemVer, string? BranchName, string? BuildMetaData, string? CommitDate, string? CustomVersion, string? EscapedBranchName, string? FullBuildMetaData, string! FullSemVer, string? InformationalVersion, string! Major, string! MajorMinorPatch, string! Minor, string! Patch, string? PreReleaseLabelName, string? PreReleaseLabelNameWithDash, string? PreReleaseNumber, string? PreReleaseLabel, string? PreReleaseLabelWithDash, string! SemVer, string? Sha, string? ShortSha, string? UncommittedChanges, string? VersionSourceDistance, string? VersionSourceIncrement, string? VersionSourceSemVer, string? VersionSourceSha, string! WeightedPreReleaseNumber) -> void GitVersion.Extensions.StringExtensions.extension(string!) GitVersion.Extensions.StringExtensions.extension(string!).IsEquivalentTo(string? other) -> bool GitVersion.Extensions.StringExtensions.extension(string!).RegexReplace(string! pattern, string! replace) -> string! diff --git a/src/GitVersion.Core/VersionCalculation/SemanticVersioning/SemanticVersionFormatValues.cs b/src/GitVersion.Core/VersionCalculation/SemanticVersioning/SemanticVersionFormatValues.cs index 06b8c9003d..5835d2be2d 100644 --- a/src/GitVersion.Core/VersionCalculation/SemanticVersioning/SemanticVersionFormatValues.cs +++ b/src/GitVersion.Core/VersionCalculation/SemanticVersioning/SemanticVersionFormatValues.cs @@ -16,21 +16,21 @@ public class SemanticVersionFormatValues(SemanticVersion semver, IGitVersionConf /// Gets the patch version component as a string. public string Patch => semver.Patch.ToString(); - /// Gets the full pre-release tag (e.g. beta.1). - public string PreReleaseTag => semver.PreReleaseTag.ToString(); + /// Gets the pre-release label name without the numeric identifier (e.g. beta). + public string PreReleaseLabelName => semver.PreReleaseTag.Name; - /// Gets the pre-release tag prefixed with a dash (e.g. -beta.1), or empty string when there is no tag. - public string PreReleaseTagWithDash => PreReleaseTag.WithPrefixIfNotNullOrEmpty("-"); - - /// Gets the pre-release label without the numeric identifier (e.g. beta). - public string PreReleaseLabel => semver.PreReleaseTag.Name; - - /// Gets the pre-release label prefixed with a dash (e.g. -beta), or empty string when there is no label. - public string PreReleaseLabelWithDash => PreReleaseLabel.WithPrefixIfNotNullOrEmpty("-"); + /// Gets the pre-release label name prefixed with a dash (e.g. -beta), or empty string when there is no label name. + public string PreReleaseLabelNameWithDash => PreReleaseLabelName.WithPrefixIfNotNullOrEmpty("-"); /// Gets the numeric pre-release identifier as a string, or empty string when absent. public string PreReleaseNumber => semver.PreReleaseTag.Number?.ToString() ?? string.Empty; + /// Gets the full pre-release label (e.g. beta.1). + public string PreReleaseLabel => semver.PreReleaseTag.ToString(); + + /// Gets the pre-release label prefixed with a dash (e.g. -beta.1), or empty string when there is no label. + public string PreReleaseLabelWithDash => PreReleaseLabel.WithPrefixIfNotNullOrEmpty("-"); + /// Gets the pre-release number adjusted by the configured pre-release weight. public string WeightedPreReleaseNumber => semver.PreReleaseTag.Number.HasValue ? $"{semver.PreReleaseTag.Number.Value + preReleaseWeight}" : $"{configuration.TagPreReleaseWeight}"; diff --git a/src/GitVersion.Core/VersionCalculation/VariableProvider.cs b/src/GitVersion.Core/VersionCalculation/VariableProvider.cs index a34730f4a2..9c5cdac4c6 100644 --- a/src/GitVersion.Core/VersionCalculation/VariableProvider.cs +++ b/src/GitVersion.Core/VersionCalculation/VariableProvider.cs @@ -64,11 +64,11 @@ public GitVersionVariables GetVariablesFor( MajorMinorPatch: semverFormatValues.MajorMinorPatch, Minor: semverFormatValues.Minor, Patch: semverFormatValues.Patch, + PreReleaseLabelName: semverFormatValues.PreReleaseLabelName, + PreReleaseLabelNameWithDash: semverFormatValues.PreReleaseLabelNameWithDash, + PreReleaseNumber: semverFormatValues.PreReleaseNumber, PreReleaseLabel: semverFormatValues.PreReleaseLabel, PreReleaseLabelWithDash: semverFormatValues.PreReleaseLabelWithDash, - PreReleaseNumber: semverFormatValues.PreReleaseNumber, - PreReleaseTag: semverFormatValues.PreReleaseTag, - PreReleaseTagWithDash: semverFormatValues.PreReleaseTagWithDash, SemVer: semverFormatValues.SemVer, Sha: semverFormatValues.Sha, ShortSha: semverFormatValues.ShortSha, diff --git a/src/GitVersion.MsBuild.Tests/Tasks/GetVersionTaskTests.cs b/src/GitVersion.MsBuild.Tests/Tasks/GetVersionTaskTests.cs index 2ca7282b1e..3ad602348f 100644 --- a/src/GitVersion.MsBuild.Tests/Tasks/GetVersionTaskTests.cs +++ b/src/GitVersion.MsBuild.Tests/Tasks/GetVersionTaskTests.cs @@ -35,6 +35,11 @@ public void GetVersionTaskShouldReturnVersionOutputVariables() result.Task.Minor.ShouldBe("2"); result.Task.Patch.ShouldBe("4"); result.Task.MajorMinorPatch.ShouldBe("1.2.4"); + result.Task.PreReleaseLabelName.ShouldBe(string.Empty); + result.Task.PreReleaseLabelNameWithDash.ShouldBe(string.Empty); + result.Task.PreReleaseNumber.ShouldBe("1"); + result.Task.PreReleaseLabel.ShouldBe("1"); + result.Task.PreReleaseLabelWithDash.ShouldBe("-1"); result.Task.FullSemVer.ShouldBe("1.2.4-1"); } @@ -51,6 +56,11 @@ public void GetVersionTaskShouldReturnVersionOutputVariablesForBuildServer() result.Task.Minor.ShouldBe("0"); result.Task.Patch.ShouldBe("1"); result.Task.MajorMinorPatch.ShouldBe("1.0.1"); + result.Task.PreReleaseLabelName.ShouldBe(string.Empty); + result.Task.PreReleaseLabelNameWithDash.ShouldBe(string.Empty); + result.Task.PreReleaseNumber.ShouldBe("1"); + result.Task.PreReleaseLabel.ShouldBe("1"); + result.Task.PreReleaseLabelWithDash.ShouldBe("-1"); result.Task.FullSemVer.ShouldBe("1.0.1-1"); } diff --git a/src/GitVersion.MsBuild/PublicAPI.Shipped.txt b/src/GitVersion.MsBuild/PublicAPI.Shipped.txt index 30a3443620..61340a344d 100644 --- a/src/GitVersion.MsBuild/PublicAPI.Shipped.txt +++ b/src/GitVersion.MsBuild/PublicAPI.Shipped.txt @@ -38,14 +38,14 @@ GitVersion.MsBuild.Tasks.GetVersion.Patch.get -> string! GitVersion.MsBuild.Tasks.GetVersion.Patch.set -> void GitVersion.MsBuild.Tasks.GetVersion.PreReleaseLabel.get -> string! GitVersion.MsBuild.Tasks.GetVersion.PreReleaseLabel.set -> void +GitVersion.MsBuild.Tasks.GetVersion.PreReleaseLabelName.get -> string! +GitVersion.MsBuild.Tasks.GetVersion.PreReleaseLabelName.set -> void +GitVersion.MsBuild.Tasks.GetVersion.PreReleaseLabelNameWithDash.get -> string! +GitVersion.MsBuild.Tasks.GetVersion.PreReleaseLabelNameWithDash.set -> void GitVersion.MsBuild.Tasks.GetVersion.PreReleaseLabelWithDash.get -> string! GitVersion.MsBuild.Tasks.GetVersion.PreReleaseLabelWithDash.set -> void GitVersion.MsBuild.Tasks.GetVersion.PreReleaseNumber.get -> string! GitVersion.MsBuild.Tasks.GetVersion.PreReleaseNumber.set -> void -GitVersion.MsBuild.Tasks.GetVersion.PreReleaseTag.get -> string! -GitVersion.MsBuild.Tasks.GetVersion.PreReleaseTag.set -> void -GitVersion.MsBuild.Tasks.GetVersion.PreReleaseTagWithDash.get -> string! -GitVersion.MsBuild.Tasks.GetVersion.PreReleaseTagWithDash.set -> void GitVersion.MsBuild.Tasks.GetVersion.SemVer.get -> string! GitVersion.MsBuild.Tasks.GetVersion.SemVer.set -> void GitVersion.MsBuild.Tasks.GetVersion.Sha.get -> string! diff --git a/src/GitVersion.MsBuild/Tasks/GetVersion.cs b/src/GitVersion.MsBuild/Tasks/GetVersion.cs index 76bbcfa4d4..4582055bdc 100644 --- a/src/GitVersion.MsBuild/Tasks/GetVersion.cs +++ b/src/GitVersion.MsBuild/Tasks/GetVersion.cs @@ -47,19 +47,19 @@ public class GetVersion : GitVersionTaskBase public string Patch { get; set; } = null!; [Output] - public string PreReleaseLabel { get; set; } = null!; + public string PreReleaseLabelName { get; set; } = null!; [Output] - public string PreReleaseLabelWithDash { get; set; } = null!; + public string PreReleaseLabelNameWithDash { get; set; } = null!; [Output] public string PreReleaseNumber { get; set; } = null!; [Output] - public string PreReleaseTag { get; set; } = null!; + public string PreReleaseLabel { get; set; } = null!; [Output] - public string PreReleaseTagWithDash { get; set; } = null!; + public string PreReleaseLabelWithDash { get; set; } = null!; [Output] public string SemVer { get; set; } = null!; diff --git a/src/GitVersion.MsBuild/msbuild/tools/GitVersion.MsBuild.targets b/src/GitVersion.MsBuild/msbuild/tools/GitVersion.MsBuild.targets index 7b649a9e33..c7351733a1 100644 --- a/src/GitVersion.MsBuild/msbuild/tools/GitVersion.MsBuild.targets +++ b/src/GitVersion.MsBuild/msbuild/tools/GitVersion.MsBuild.targets @@ -50,11 +50,11 @@ + + + - - - @@ -69,7 +69,7 @@ $(GitVersion_SemVer) $(GitVersion_MajorMinorPatch) - $(GitVersion_PreReleaseTag) + $(GitVersion_PreReleaseLabel) $(GitVersion_FullSemVer) $(GitVersion_InformationalVersion) $(GitVersion_AssemblySemVer) @@ -92,11 +92,11 @@ GitVersion_MajorMinorPatch=$(GitVersion_MajorMinorPatch);$(DefineConstants) GitVersion_Minor=$(GitVersion_Minor);$(DefineConstants) GitVersion_Patch=$(GitVersion_Patch);$(DefineConstants) + GitVersion_PreReleaseLabelName=$(GitVersion_PreReleaseLabelName);$(DefineConstants) + GitVersion_PreReleaseLabelNameWithDash=$(GitVersion_PreReleaseLabelNameWithDash);$(DefineConstants) + GitVersion_PreReleaseNumber=$(GitVersion_PreReleaseNumber);$(DefineConstants) GitVersion_PreReleaseLabel=$(GitVersion_PreReleaseLabel);$(DefineConstants) GitVersion_PreReleaseLabelWithDash=$(GitVersion_PreReleaseLabelWithDash);$(DefineConstants) - GitVersion_PreReleaseNumber=$(GitVersion_PreReleaseNumber);$(DefineConstants) - GitVersion_PreReleaseTag=$(GitVersion_PreReleaseTag);$(DefineConstants) - GitVersion_PreReleaseTagWithDash=$(GitVersion_PreReleaseTagWithDash);$(DefineConstants) GitVersion_SemVer=$(GitVersion_SemVer);$(DefineConstants) GitVersion_Sha=$(GitVersion_Sha);$(DefineConstants) GitVersion_ShortSha=$(GitVersion_ShortSha);$(DefineConstants) diff --git a/src/GitVersion.Output.Tests/Output/Approved/WixFileTests.UpdateWixVersionFile.approved.txt b/src/GitVersion.Output.Tests/Output/Approved/WixFileTests.UpdateWixVersionFile.approved.txt index 7834eac671..959a63a98c 100644 --- a/src/GitVersion.Output.Tests/Output/Approved/WixFileTests.UpdateWixVersionFile.approved.txt +++ b/src/GitVersion.Output.Tests/Output/Approved/WixFileTests.UpdateWixVersionFile.approved.txt @@ -15,10 +15,10 @@ + + - - diff --git a/src/GitVersion.Output.Tests/Output/Approved/WixFileTests.UpdateWixVersionFileWhenFileAlreadyExists.approved.txt b/src/GitVersion.Output.Tests/Output/Approved/WixFileTests.UpdateWixVersionFileWhenFileAlreadyExists.approved.txt index 7834eac671..959a63a98c 100644 --- a/src/GitVersion.Output.Tests/Output/Approved/WixFileTests.UpdateWixVersionFileWhenFileAlreadyExists.approved.txt +++ b/src/GitVersion.Output.Tests/Output/Approved/WixFileTests.UpdateWixVersionFileWhenFileAlreadyExists.approved.txt @@ -15,10 +15,10 @@ + + - - diff --git a/src/GitVersion.Output.Tests/Output/Approved/cs/GitVersionInfoGeneratorTests.ShouldCreateFile.approved.txt b/src/GitVersion.Output.Tests/Output/Approved/cs/GitVersionInfoGeneratorTests.ShouldCreateFile.approved.txt index 9f063f1a43..415275856c 100644 --- a/src/GitVersion.Output.Tests/Output/Approved/cs/GitVersionInfoGeneratorTests.ShouldCreateFile.approved.txt +++ b/src/GitVersion.Output.Tests/Output/Approved/cs/GitVersionInfoGeneratorTests.ShouldCreateFile.approved.txt @@ -26,11 +26,11 @@ static class GitVersionInformation public const string MajorMinorPatch = "1.2.3"; public const string Minor = "2"; public const string Patch = "3"; - public const string PreReleaseLabel = "unstable"; - public const string PreReleaseLabelWithDash = "-unstable"; + public const string PreReleaseLabel = "unstable.4"; + public const string PreReleaseLabelName = "unstable"; + public const string PreReleaseLabelNameWithDash = "-unstable"; + public const string PreReleaseLabelWithDash = "-unstable.4"; public const string PreReleaseNumber = "4"; - public const string PreReleaseTag = "unstable.4"; - public const string PreReleaseTagWithDash = "-unstable.4"; public const string SemVer = "1.2.3-unstable.4"; public const string Sha = "commitSha"; public const string ShortSha = "commitShortSha"; diff --git a/src/GitVersion.Output.Tests/Output/Approved/cs/GitVersionInfoGeneratorTests.ShouldProperlyOutputNamespaceDeclaration.approved.txt b/src/GitVersion.Output.Tests/Output/Approved/cs/GitVersionInfoGeneratorTests.ShouldProperlyOutputNamespaceDeclaration.approved.txt index e4d115510a..1ca3823c1c 100644 --- a/src/GitVersion.Output.Tests/Output/Approved/cs/GitVersionInfoGeneratorTests.ShouldProperlyOutputNamespaceDeclaration.approved.txt +++ b/src/GitVersion.Output.Tests/Output/Approved/cs/GitVersionInfoGeneratorTests.ShouldProperlyOutputNamespaceDeclaration.approved.txt @@ -28,11 +28,11 @@ namespace My.Custom.Namespace public const string MajorMinorPatch = "1.2.3"; public const string Minor = "2"; public const string Patch = "3"; - public const string PreReleaseLabel = "unstable"; - public const string PreReleaseLabelWithDash = "-unstable"; + public const string PreReleaseLabel = "unstable.4"; + public const string PreReleaseLabelName = "unstable"; + public const string PreReleaseLabelNameWithDash = "-unstable"; + public const string PreReleaseLabelWithDash = "-unstable.4"; public const string PreReleaseNumber = "4"; - public const string PreReleaseTag = "unstable.4"; - public const string PreReleaseTagWithDash = "-unstable.4"; public const string SemVer = "1.2.3-unstable.4"; public const string Sha = "commitSha"; public const string ShortSha = "commitShortSha"; diff --git a/src/GitVersion.Output.Tests/Output/Approved/fs/GitVersionInfoGeneratorTests.ShouldCreateFile.approved.txt b/src/GitVersion.Output.Tests/Output/Approved/fs/GitVersionInfoGeneratorTests.ShouldCreateFile.approved.txt index 4711427033..7f0c46a603 100644 --- a/src/GitVersion.Output.Tests/Output/Approved/fs/GitVersionInfoGeneratorTests.ShouldCreateFile.approved.txt +++ b/src/GitVersion.Output.Tests/Output/Approved/fs/GitVersionInfoGeneratorTests.ShouldCreateFile.approved.txt @@ -28,11 +28,11 @@ type GitVersionInformation = static member MajorMinorPatch = "1.2.3" static member Minor = "2" static member Patch = "3" - static member PreReleaseLabel = "unstable" - static member PreReleaseLabelWithDash = "-unstable" + static member PreReleaseLabel = "unstable.4" + static member PreReleaseLabelName = "unstable" + static member PreReleaseLabelNameWithDash = "-unstable" + static member PreReleaseLabelWithDash = "-unstable.4" static member PreReleaseNumber = "4" - static member PreReleaseTag = "unstable.4" - static member PreReleaseTagWithDash = "-unstable.4" static member SemVer = "1.2.3-unstable.4" static member Sha = "commitSha" static member ShortSha = "commitShortSha" diff --git a/src/GitVersion.Output.Tests/Output/Approved/fs/GitVersionInfoGeneratorTests.ShouldProperlyOutputNamespaceDeclaration.approved.txt b/src/GitVersion.Output.Tests/Output/Approved/fs/GitVersionInfoGeneratorTests.ShouldProperlyOutputNamespaceDeclaration.approved.txt index 071b9018a0..3d71f6644e 100644 --- a/src/GitVersion.Output.Tests/Output/Approved/fs/GitVersionInfoGeneratorTests.ShouldProperlyOutputNamespaceDeclaration.approved.txt +++ b/src/GitVersion.Output.Tests/Output/Approved/fs/GitVersionInfoGeneratorTests.ShouldProperlyOutputNamespaceDeclaration.approved.txt @@ -28,11 +28,11 @@ type GitVersionInformation = static member MajorMinorPatch = "1.2.3" static member Minor = "2" static member Patch = "3" - static member PreReleaseLabel = "unstable" - static member PreReleaseLabelWithDash = "-unstable" + static member PreReleaseLabel = "unstable.4" + static member PreReleaseLabelName = "unstable" + static member PreReleaseLabelNameWithDash = "-unstable" + static member PreReleaseLabelWithDash = "-unstable.4" static member PreReleaseNumber = "4" - static member PreReleaseTag = "unstable.4" - static member PreReleaseTagWithDash = "-unstable.4" static member SemVer = "1.2.3-unstable.4" static member Sha = "commitSha" static member ShortSha = "commitShortSha" diff --git a/src/GitVersion.Output.Tests/Output/Approved/vb/GitVersionInfoGeneratorTests.ShouldCreateFile.approved.txt b/src/GitVersion.Output.Tests/Output/Approved/vb/GitVersionInfoGeneratorTests.ShouldCreateFile.approved.txt index 91f3d8bbd5..0c58687225 100644 --- a/src/GitVersion.Output.Tests/Output/Approved/vb/GitVersionInfoGeneratorTests.ShouldCreateFile.approved.txt +++ b/src/GitVersion.Output.Tests/Output/Approved/vb/GitVersionInfoGeneratorTests.ShouldCreateFile.approved.txt @@ -29,11 +29,11 @@ Namespace Global Public Shared MajorMinorPatch As String = "1.2.3" Public Shared Minor As String = "2" Public Shared Patch As String = "3" - Public Shared PreReleaseLabel As String = "unstable" - Public Shared PreReleaseLabelWithDash As String = "-unstable" + Public Shared PreReleaseLabel As String = "unstable.4" + Public Shared PreReleaseLabelName As String = "unstable" + Public Shared PreReleaseLabelNameWithDash As String = "-unstable" + Public Shared PreReleaseLabelWithDash As String = "-unstable.4" Public Shared PreReleaseNumber As String = "4" - Public Shared PreReleaseTag As String = "unstable.4" - Public Shared PreReleaseTagWithDash As String = "-unstable.4" Public Shared SemVer As String = "1.2.3-unstable.4" Public Shared Sha As String = "commitSha" Public Shared ShortSha As String = "commitShortSha" diff --git a/src/GitVersion.Output.Tests/Output/Approved/vb/GitVersionInfoGeneratorTests.ShouldProperlyOutputNamespaceDeclaration.approved.txt b/src/GitVersion.Output.Tests/Output/Approved/vb/GitVersionInfoGeneratorTests.ShouldProperlyOutputNamespaceDeclaration.approved.txt index 6c80d3662b..df357f7686 100644 --- a/src/GitVersion.Output.Tests/Output/Approved/vb/GitVersionInfoGeneratorTests.ShouldProperlyOutputNamespaceDeclaration.approved.txt +++ b/src/GitVersion.Output.Tests/Output/Approved/vb/GitVersionInfoGeneratorTests.ShouldProperlyOutputNamespaceDeclaration.approved.txt @@ -29,11 +29,11 @@ Namespace My.Custom.Namespace Public Shared MajorMinorPatch As String = "1.2.3" Public Shared Minor As String = "2" Public Shared Patch As String = "3" - Public Shared PreReleaseLabel As String = "unstable" - Public Shared PreReleaseLabelWithDash As String = "-unstable" + Public Shared PreReleaseLabel As String = "unstable.4" + Public Shared PreReleaseLabelName As String = "unstable" + Public Shared PreReleaseLabelNameWithDash As String = "-unstable" + Public Shared PreReleaseLabelWithDash As String = "-unstable.4" Public Shared PreReleaseNumber As String = "4" - Public Shared PreReleaseTag As String = "unstable.4" - Public Shared PreReleaseTagWithDash As String = "-unstable.4" Public Shared SemVer As String = "1.2.3-unstable.4" Public Shared Sha As String = "commitSha" Public Shared ShortSha As String = "commitShortSha" diff --git a/src/GitVersion.Output.Tests/Output/FormatArgumentTests.cs b/src/GitVersion.Output.Tests/Output/FormatArgumentTests.cs index 8123fc27bc..2b47a52cb1 100644 --- a/src/GitVersion.Output.Tests/Output/FormatArgumentTests.cs +++ b/src/GitVersion.Output.Tests/Output/FormatArgumentTests.cs @@ -11,7 +11,8 @@ public class FormatArgumentTests : TestBase [TestCase("{SemVer}", "1.1.0-foo.1")] [TestCase("{Major}.{Minor}", "1.1")] [TestCase("{Major}.{Minor}.{Patch}", "1.1.0")] - [TestCase("{Major}.{Minor}.{Patch}.{PreReleaseTag}", "1.1.0.foo.1")] + [TestCase("{Major}.{Minor}.{Patch}.{PreReleaseLabel}", "1.1.0.foo.1")] + [TestCase("{PreReleaseLabelName}", "foo")] public void ShouldOutputFormatTests(string format, string expectedValue) { using var fixture = CreateTestRepository(); @@ -69,7 +70,10 @@ public void ShouldOutputFormatWithEnvironmentVariablesTests(string format, strin [TestCase("Major", "'1'")] [TestCase("MajorMinorPatch", "'1.1.0'")] [TestCase("SemVer", "'1.1.0-foo.1'")] - [TestCase("PreReleaseTagWithDash", "'-foo.1'")] + [TestCase("PreReleaseLabel", "'foo.1'")] + [TestCase("PreReleaseLabelName", "'foo'")] + [TestCase("PreReleaseLabelWithDash", "'-foo.1'")] + [TestCase("PreReleaseLabelNameWithDash", "'-foo'")] [TestCase("AssemblySemFileVer", "'1.1.0.0'")] [TestCase("BranchName", "'feature/foo'")] [TestCase("FullSemVer", "'1.1.0-foo.1+1'")] @@ -130,10 +134,11 @@ public void ShouldOutputAllCalculatedVariablesAsDotEnvEntries() [TestCase("SemVer", "'0.0.1-1'")] [TestCase("BuildMetaData", "''")] [TestCase("AssemblySemVer", "'0.0.1.0'")] - [TestCase("PreReleaseTagWithDash", "'-1'")] + [TestCase("PreReleaseLabel", "'1'")] + [TestCase("PreReleaseLabelWithDash", "'-1'")] [TestCase("BranchName", "'main'")] - [TestCase("PreReleaseLabel", "''")] - [TestCase("PreReleaseLabelWithDash", "''")] + [TestCase("PreReleaseLabelName", "''")] + [TestCase("PreReleaseLabelNameWithDash", "''")] public void ShouldOutputAllDotEnvEntriesEvenForMinimalRepositories(string variableName, string expectedValue) { using var fixture = CreateMinimalTestRepository(); diff --git a/src/GitVersion.Output/Serializer/VersionVariablesJsonModel.cs b/src/GitVersion.Output/Serializer/VersionVariablesJsonModel.cs index 5bf85a2741..fce35e8ca1 100644 --- a/src/GitVersion.Output/Serializer/VersionVariablesJsonModel.cs +++ b/src/GitVersion.Output/Serializer/VersionVariablesJsonModel.cs @@ -46,22 +46,22 @@ internal class VersionVariablesJsonModel [JsonPropertyDescription("The patch version. Should be incremented on bug fixes.")] public int? Patch { get; set; } - [JsonPropertyDescription("The pre-release label is the name of the pre-release.")] - public string? PreReleaseLabel { get; set; } + [JsonPropertyDescription("The name of the pre-release label, without the PreReleaseNumber.")] + public string? PreReleaseLabelName { get; set; } - [JsonPropertyDescription("The pre-release label prefixed with a dash.")] - public string? PreReleaseLabelWithDash { get; set; } + [JsonPropertyDescription("The pre-release label name prefixed with a dash.")] + public string? PreReleaseLabelNameWithDash { get; set; } [JsonPropertyDescription("The pre-release number is the number of commits since the last version bump.")] public int? PreReleaseNumber { get; set; } - [JsonPropertyDescription("The pre-release tag is the pre-release label suffixed by the PreReleaseNumber.")] - public string? PreReleaseTag { get; set; } + [JsonPropertyDescription("The full pre-release label, including the PreReleaseNumber when present.")] + public string? PreReleaseLabel { get; set; } - [JsonPropertyDescription("The pre-release tag prefixed with a dash.")] - public string? PreReleaseTagWithDash { get; set; } + [JsonPropertyDescription("The pre-release label prefixed with a dash.")] + public string? PreReleaseLabelWithDash { get; set; } - [JsonPropertyDescription("The semantic version number, including PreReleaseTagWithDash for pre-release version numbers.")] + [JsonPropertyDescription("The semantic version number, including PreReleaseLabelWithDash for pre-release version numbers.")] public string? SemVer { get; set; } [JsonPropertyDescription("The SHA of the Git commit.")] From 35e70ca42d1bcae5773a55c79db5a37d2709b504 Mon Sep 17 00:00:00 2001 From: Artur Stolear Date: Thu, 30 Jul 2026 19:32:33 +0200 Subject: [PATCH 2/2] docs: document pre-release variable migration --- BREAKING_CHANGES.md | 13 +++++++++++++ docs/input/docs/migration/v6-to-v7.md | 17 +++++++++++++++++ .../reference/build-servers/octopus-deploy.md | 2 +- docs/input/docs/reference/configuration.md | 2 +- docs/input/docs/reference/custom-formatting.md | 8 ++++---- .../reference/mdsource/configuration.source.md | 2 +- docs/input/docs/reference/variables.md | 18 +++++++++--------- 7 files changed, 46 insertions(+), 16 deletions(-) diff --git a/BREAKING_CHANGES.md b/BREAKING_CHANGES.md index 38d00f6146..4d9128c1f5 100644 --- a/BREAKING_CHANGES.md +++ b/BREAKING_CHANGES.md @@ -1,5 +1,18 @@ ## Unreleased +### Pre-release output variables renamed + +The pre-release output variables now use SemVer label terminology consistently: + +| Previous variable | Replacement | Example value | +| --- | --- | --- | +| `PreReleaseTag` | `PreReleaseLabel` | `beta.99` | +| `PreReleaseTagWithDash` | `PreReleaseLabelWithDash` | `-beta.99` | +| `PreReleaseLabel` | `PreReleaseLabelName` | `beta` | +| `PreReleaseLabelWithDash` | `PreReleaseLabelNameWithDash` | `-beta` | + +The change applies to JSON output, formatting variables, build-agent environment variables, generated version-information files, and `GitVersion.MsBuild` outputs. `PreReleaseNumber` is unchanged. + ### .NET 8 and .NET 9 target frameworks removed GitVersion now targets .NET 10 only. The CLI, global tool, and `GitVersion.MsBuild` require a .NET 10 runtime. The MSBuild integration continues to support projects targeting earlier frameworks through its `dotnet exec --roll-forward Major` launcher, provided .NET 10 is installed. diff --git a/docs/input/docs/migration/v6-to-v7.md b/docs/input/docs/migration/v6-to-v7.md index da0d0b5c76..033348242d 100644 --- a/docs/input/docs/migration/v6-to-v7.md +++ b/docs/input/docs/migration/v6-to-v7.md @@ -6,6 +6,23 @@ Description: Migration guidance for upgrading from GitVersion v6 to GitVersion v This document summarizes the relevant breaking changes when migrating from GitVersion v6 to v7. +## Pre-release output variables renamed + +The pre-release output variables now use SemVer terminology consistently. Update JSON consumers, `--show-variable` arguments, custom format strings, build-agent environment variables, generated version-information files, and `GitVersion.MsBuild` properties according to this mapping: + +| GitVersion v6 | GitVersion v7 | Example value | +| --- | --- | --- | +| `PreReleaseTag` | `PreReleaseLabel` | `beta.99` | +| `PreReleaseTagWithDash` | `PreReleaseLabelWithDash` | `-beta.99` | +| `PreReleaseLabel` | `PreReleaseLabelName` | `beta` | +| `PreReleaseLabelWithDash` | `PreReleaseLabelNameWithDash` | `-beta` | + +`PreReleaseNumber` is unchanged. In MSBuild and build-agent environments, apply the same mapping to the `GitVersion_`-prefixed names. For example, `GitVersion_PreReleaseTag` becomes `GitVersion_PreReleaseLabel`. + +:::{.alert .alert-warning} +`PreReleaseLabel` and `PreReleaseLabelWithDash` retain their names but change from the label name (`beta`) to the full label (`beta.99`). Consumers that require only the name must use `PreReleaseLabelName` and `PreReleaseLabelNameWithDash`. +::: + ## Intel macOS artifacts removed GitVersion v7 no longer ships native `osx-x64` artifacts. Apple Silicon (`osx-arm64`) is now the only supported macOS target. Intel Mac users should continue using the last GitVersion v6 release that shipped an `osx-x64` artifact. diff --git a/docs/input/docs/reference/build-servers/octopus-deploy.md b/docs/input/docs/reference/build-servers/octopus-deploy.md index f7054ae549..d687d199d5 100644 --- a/docs/input/docs/reference/build-servers/octopus-deploy.md +++ b/docs/input/docs/reference/build-servers/octopus-deploy.md @@ -162,7 +162,7 @@ $nugetVersion = $versionInfo.NuGetVersion msbuild MyProj.sln # Only create nuget package for stable -if ($versionInfo.PreReleaseTag -eq '') +if ($versionInfo.PreReleaseLabel -eq '') { Write-Host Write-Host "Creating a release" -ForegroundColor Magenta diff --git a/docs/input/docs/reference/configuration.md b/docs/input/docs/reference/configuration.md index 5c831a0975..2fe3e9fe8d 100644 --- a/docs/input/docs/reference/configuration.md +++ b/docs/input/docs/reference/configuration.md @@ -999,7 +999,7 @@ This indicates that this branch is a main branch. By default `main` and `support ### pre-release-weight -Provides a way to translate the `PreReleaseLabel` ([variables][variables]) to a numeric +Provides a way to translate the `PreReleaseLabelName` ([variables][variables]) to a numeric value in order to avoid version collisions across different branches. For example, a release branch created after "1.2.3-alpha.55" results in "1.2.3-beta.1" and thus e.g. "1.2.3-alpha.4" and "1.2.3-beta.4" would have the diff --git a/docs/input/docs/reference/custom-formatting.md b/docs/input/docs/reference/custom-formatting.md index 2f5fa170b7..7ffc2459ab 100644 --- a/docs/input/docs/reference/custom-formatting.md +++ b/docs/input/docs/reference/custom-formatting.md @@ -18,7 +18,7 @@ For example, a PEP 440-compatible pre-release version can omit SemVer's dash and separator: ```yaml -custom-version-format: '{Major}.{Minor}.{Patch}{PreReleaseLabel:l}{PreReleaseNumber}' +custom-version-format: '{Major}.{Minor}.{Patch}{PreReleaseLabelName:l}{PreReleaseNumber}' # 0.6.3-beta.10 becomes CustomVersion 0.6.3beta10 ``` @@ -28,7 +28,7 @@ For example, a branch-specific format can override the global default: custom-version-format: '{SemVer}' branches: feature: - custom-version-format: '{Major}.{Minor}.{Patch}{PreReleaseLabel:l}{PreReleaseNumber}' + custom-version-format: '{Major}.{Minor}.{Patch}{PreReleaseLabelName:l}{PreReleaseNumber}' ``` A fixed-width numeric format can provide an increasing integer version for @@ -64,7 +64,7 @@ You can now use standard .NET numeric format strings with version components: ```yaml # GitVersion.yml -assembly-informational-format: "{Major}.{Minor}.{Patch:F2}-{PreReleaseLabel}" +assembly-informational-format: "{Major}.{Minor}.{Patch:F2}-{PreReleaseLabelName}" ``` **Supported Numeric Formats:** @@ -114,7 +114,7 @@ branches: feature: label: "{BranchName:c}" # Converts to PascalCase -assembly-informational-format: "{Major}.{Minor}.{Patch}-{PreReleaseLabel:l}.{VersionSourceDistance:0000}" +assembly-informational-format: "{Major}.{Minor}.{Patch}-{PreReleaseLabelName:l}.{VersionSourceDistance:0000}" ``` **Template Usage:** diff --git a/docs/input/docs/reference/mdsource/configuration.source.md b/docs/input/docs/reference/mdsource/configuration.source.md index c0dbad858a..154c530481 100644 --- a/docs/input/docs/reference/mdsource/configuration.source.md +++ b/docs/input/docs/reference/mdsource/configuration.source.md @@ -600,7 +600,7 @@ This indicates that this branch is a main branch. By default `main` and `support ### pre-release-weight -Provides a way to translate the `PreReleaseLabel` ([variables][variables]) to a numeric +Provides a way to translate the `PreReleaseLabelName` ([variables][variables]) to a numeric value in order to avoid version collisions across different branches. For example, a release branch created after "1.2.3-alpha.55" results in "1.2.3-beta.1" and thus e.g. "1.2.3-alpha.4" and "1.2.3-beta.4" would have the diff --git a/docs/input/docs/reference/variables.md b/docs/input/docs/reference/variables.md index b9c2685a33..e467d1b3a3 100644 --- a/docs/input/docs/reference/variables.md +++ b/docs/input/docs/reference/variables.md @@ -25,11 +25,11 @@ what is available. For the `release/3.0.0` branch of GitVersion it shows: "MajorMinorPatch": "3.22.11", "Minor": 22, "Patch": 11, - "PreReleaseLabel": "beta", - "PreReleaseLabelWithDash": "-beta", + "PreReleaseLabelName": "beta", + "PreReleaseLabelNameWithDash": "-beta", "PreReleaseNumber": 99, - "PreReleaseTag": "beta.99", - "PreReleaseTagWithDash": "-beta.99", + "PreReleaseLabel": "beta.99", + "PreReleaseLabelWithDash": "-beta.99", "SemVer": "3.22.11-beta.99", "Sha": "28c853159a46b5a87e6cc9c4f6e940c59d6bc68a", "ShortSha": "28c8531", @@ -60,12 +60,12 @@ Each property of the above JSON document is described in the below table. | `MajorMinorPatch` | `Major`, `Minor` and `Patch` joined together, separated by `.`. | | `Minor` | The minor version. Should be incremented on new features. | | `Patch` | The patch version. Should be incremented on bug fixes. | -| `PreReleaseLabel` | The pre-release label. | -| `PreReleaseLabelWithDash` | The pre-release label prefixed with a dash. | +| `PreReleaseLabelName` | The name of the pre-release label, without the `PreReleaseNumber`. | +| `PreReleaseLabelNameWithDash` | The pre-release label name prefixed with a dash. | | `PreReleaseNumber` | The pre-release number. | -| `PreReleaseTag` | The pre-release tag is the pre-release label suffixed by the `PreReleaseNumber`. | -| `PreReleaseTagWithDash` | The pre-release tag prefixed with a dash. | -| `SemVer` | The semantical version number, including `PreReleaseTagWithDash` for pre-release version numbers. | +| `PreReleaseLabel` | The full pre-release label, including the `PreReleaseNumber` when present. | +| `PreReleaseLabelWithDash` | The pre-release label prefixed with a dash. | +| `SemVer` | The semantic version number, including `PreReleaseLabelWithDash` for pre-release version numbers. | | `Sha` | The SHA of the Git commit. | | `ShortSha` | The `Sha` limited to 7 characters. | | `UncommittedChanges` | The number of uncommitted changes present in the repository. |