From a9ef617fbf8e23c7c24b737255c1b0556a36752c Mon Sep 17 00:00:00 2001 From: Alexander Pykavy Date: Mon, 26 Sep 2022 21:12:26 +0200 Subject: [PATCH] Don't consider "tag-prefix" as optional if it's explicitly specified To correctly calculate the next version with the prefix. For example, we develop the main product and some its plugin in the same repository and have the following git tags list: - 0.1.0 - 0.1.1 - 0.2.0 - 0.2.1 - plugin_0.1.0 - plugin_0.1.1 The expected next plugin version is `0.1.2` not `0.2.2` (`plugin_` prefix will be prepended before setting the tag). --- ...ProviderTests.CanWriteOutEffectiveConfiguration.approved.txt | 2 +- src/GitVersion.Core/Configuration/GitVersionConfiguration.cs | 2 +- src/GitVersion.Core/PublicAPI.Shipped.txt | 2 +- .../VersionCalculation/SemanticVersioning/SemanticVersion.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/GitVersion.Core.Tests/Configuration/ConfigurationProviderTests.CanWriteOutEffectiveConfiguration.approved.txt b/src/GitVersion.Core.Tests/Configuration/ConfigurationProviderTests.CanWriteOutEffectiveConfiguration.approved.txt index f141ccc585..f2943e4f82 100644 --- a/src/GitVersion.Core.Tests/Configuration/ConfigurationProviderTests.CanWriteOutEffectiveConfiguration.approved.txt +++ b/src/GitVersion.Core.Tests/Configuration/ConfigurationProviderTests.CanWriteOutEffectiveConfiguration.approved.txt @@ -1,7 +1,7 @@ assembly-versioning-scheme: MajorMinorPatch assembly-file-versioning-scheme: MajorMinorPatch mode: ContinuousDelivery -tag-prefix: '[vV]' +tag-prefix: '[vV]?' continuous-delivery-fallback-tag: ci major-version-bump-message: '\+semver:\s?(breaking|major)' minor-version-bump-message: '\+semver:\s?(feature|minor)' diff --git a/src/GitVersion.Core/Configuration/GitVersionConfiguration.cs b/src/GitVersion.Core/Configuration/GitVersionConfiguration.cs index 497a366258..3db85ce0f5 100644 --- a/src/GitVersion.Core/Configuration/GitVersionConfiguration.cs +++ b/src/GitVersion.Core/Configuration/GitVersionConfiguration.cs @@ -97,7 +97,7 @@ public override string ToString() return stringBuilder.ToString(); } - public const string DefaultTagPrefix = "[vV]"; + public const string DefaultTagPrefix = "[vV]?"; public const string ReleaseBranchRegex = "^releases?[/-]"; public const string FeatureBranchRegex = "^features?[/-]"; public const string PullRequestRegex = @"^(pull|pull\-requests|pr)[/-]"; diff --git a/src/GitVersion.Core/PublicAPI.Shipped.txt b/src/GitVersion.Core/PublicAPI.Shipped.txt index a05ee98e2e..c8b8b5622f 100644 --- a/src/GitVersion.Core/PublicAPI.Shipped.txt +++ b/src/GitVersion.Core/PublicAPI.Shipped.txt @@ -28,7 +28,7 @@ const GitVersion.BuildAgents.SpaceAutomation.EnvironmentVariableName = "JB_SPACE const GitVersion.BuildAgents.TeamCity.EnvironmentVariableName = "TEAMCITY_VERSION" -> string! const GitVersion.BuildAgents.TravisCi.EnvironmentVariableName = "TRAVIS" -> string! const GitVersion.Configuration.ConfigurationFileLocator.DefaultFileName = "GitVersion.yml" -> string! -const GitVersion.Configuration.GitVersionConfiguration.DefaultTagPrefix = "[vV]" -> string! +const GitVersion.Configuration.GitVersionConfiguration.DefaultTagPrefix = "[vV]?" -> string! const GitVersion.Configuration.GitVersionConfiguration.DevelopBranchKey = "develop" -> string! const GitVersion.Configuration.GitVersionConfiguration.DevelopBranchRegex = "^dev(elop)?(ment)?$" -> string! const GitVersion.Configuration.GitVersionConfiguration.FeatureBranchKey = "feature" -> string! diff --git a/src/GitVersion.Core/VersionCalculation/SemanticVersioning/SemanticVersion.cs b/src/GitVersion.Core/VersionCalculation/SemanticVersioning/SemanticVersion.cs index 7918fe5e6d..3394a66e44 100644 --- a/src/GitVersion.Core/VersionCalculation/SemanticVersioning/SemanticVersion.cs +++ b/src/GitVersion.Core/VersionCalculation/SemanticVersioning/SemanticVersion.cs @@ -143,7 +143,7 @@ public static SemanticVersion Parse(string version, string? tagPrefixRegex, Sema public static bool TryParse(string version, string? tagPrefixRegex, [NotNullWhen(true)] out SemanticVersion? semanticVersion, SemanticVersionFormat format = SemanticVersionFormat.Strict) { - var match = Regex.Match(version, $"^({tagPrefixRegex})?(?.*)$"); + var match = Regex.Match(version, $"^({tagPrefixRegex})(?.*)$"); if (!match.Success) {