diff --git a/src/GitVersion.Core.Tests/Configuration/ConfigProviderTests.CanWriteOutEffectiveConfiguration.approved.txt b/src/GitVersion.Core.Tests/Configuration/ConfigProviderTests.CanWriteOutEffectiveConfiguration.approved.txt index c3749b2a40..1d3990cd27 100644 --- a/src/GitVersion.Core.Tests/Configuration/ConfigProviderTests.CanWriteOutEffectiveConfiguration.approved.txt +++ b/src/GitVersion.Core.Tests/Configuration/ConfigProviderTests.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.Tests/Configuration/ConfigProviderTests.cs b/src/GitVersion.Core.Tests/Configuration/ConfigProviderTests.cs index 82cd710c25..bb7b4cefd8 100644 --- a/src/GitVersion.Core.Tests/Configuration/ConfigProviderTests.cs +++ b/src/GitVersion.Core.Tests/Configuration/ConfigProviderTests.cs @@ -461,7 +461,7 @@ public void ShouldUseDefaultTagPrefixWhenNotSetInConfigFile() SetupConfigFileContent(text); var config = this.configProvider.Provide(this.repoPath); - config.TagPrefix.ShouldBe("[vV]"); + config.TagPrefix.ShouldBe(Config.DefaultTagPrefix); } [Test] @@ -491,7 +491,7 @@ public void ShouldNotOverrideDefaultTagPrefixWhenNotSetInOverrideConfig() SetupConfigFileContent(text); var config = this.configProvider.Provide(this.repoPath, new Config { TagPrefix = null }); - config.TagPrefix.ShouldBe("[vV]"); + config.TagPrefix.ShouldBe(Config.DefaultTagPrefix); } [Test] diff --git a/src/GitVersion.Core.Tests/Helpers/TestEffectiveConfiguration.cs b/src/GitVersion.Core.Tests/Helpers/TestEffectiveConfiguration.cs index 98991ec0ac..9f60987d52 100644 --- a/src/GitVersion.Core.Tests/Helpers/TestEffectiveConfiguration.cs +++ b/src/GitVersion.Core.Tests/Helpers/TestEffectiveConfiguration.cs @@ -13,7 +13,7 @@ public TestEffectiveConfiguration( string? assemblyFileVersioningFormat = null, string? assemblyInformationalFormat = null, VersioningMode versioningMode = VersioningMode.ContinuousDelivery, - string tagPrefix = "v", + string tagPrefix = "v?", string tag = "", string? nextVersion = null, string branchPrefixToTrim = "", diff --git a/src/GitVersion.Core.Tests/Model/MergeMessageTests.cs b/src/GitVersion.Core.Tests/Model/MergeMessageTests.cs index 132e8526b1..9d441619db 100644 --- a/src/GitVersion.Core.Tests/Model/MergeMessageTests.cs +++ b/src/GitVersion.Core.Tests/Model/MergeMessageTests.cs @@ -8,7 +8,7 @@ namespace GitVersion.Core.Tests; [TestFixture] public class MergeMessageTests : TestBase { - private readonly Config config = new() { TagPrefix = "[vV]" }; + private readonly Config config = new() { TagPrefix = Config.DefaultTagPrefix }; [Test] public void NullMessageStringThrows() => diff --git a/src/GitVersion.Core.Tests/VersionCalculation/SemanticVersionTests.cs b/src/GitVersion.Core.Tests/VersionCalculation/SemanticVersionTests.cs index 58caf701de..13c3165f58 100644 --- a/src/GitVersion.Core.Tests/VersionCalculation/SemanticVersionTests.cs +++ b/src/GitVersion.Core.Tests/VersionCalculation/SemanticVersionTests.cs @@ -65,6 +65,7 @@ public void ValidateVersionParsing( [TestCase("someText")] [TestCase("some-T-ext")] [TestCase("v.1.2.3", "v")] + [TestCase("1.2.3", "v")] public void ValidateInvalidVersionParsing(string versionString, string? tagPrefixRegex = null) => Assert.IsFalse(SemanticVersion.TryParse(versionString, tagPrefixRegex, out _), "TryParse Result"); diff --git a/src/GitVersion.Core.Tests/VersionConverters/AssemblyInfoFileUpdaterTests.cs b/src/GitVersion.Core.Tests/VersionConverters/AssemblyInfoFileUpdaterTests.cs index d0f95dbd83..860c8607f7 100644 --- a/src/GitVersion.Core.Tests/VersionConverters/AssemblyInfoFileUpdaterTests.cs +++ b/src/GitVersion.Core.Tests/VersionConverters/AssemblyInfoFileUpdaterTests.cs @@ -42,7 +42,7 @@ public void ShouldCreateAssemblyInfoFileWhenNotExistsAndEnsureAssemblyInfo(strin var workingDir = Path.GetTempPath(); var assemblyInfoFile = "VersionAssemblyInfo." + fileExtension; var fullPath = PathHelper.Combine(workingDir, assemblyInfoFile); - var variables = this.variableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false); + var variables = this.variableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v?"), new TestEffectiveConfiguration(), false); using var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(this.log, this.fileSystem); assemblyInfoFileUpdater.Execute(variables, new AssemblyInfoContext(workingDir, true, assemblyInfoFile)); @@ -60,7 +60,7 @@ public void ShouldCreateAssemblyInfoFileAtPathWhenNotExistsAndEnsureAssemblyInfo var workingDir = Path.GetTempPath(); var assemblyInfoFile = PathHelper.Combine("src", "Project", "Properties", $"VersionAssemblyInfo.{fileExtension}"); var fullPath = PathHelper.Combine(workingDir, assemblyInfoFile); - var variables = this.variableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false); + var variables = this.variableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v?"), new TestEffectiveConfiguration(), false); using var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(this.log, this.fileSystem); assemblyInfoFileUpdater.Execute(variables, new AssemblyInfoContext(workingDir, true, assemblyInfoFile)); @@ -81,7 +81,7 @@ public void ShouldCreateAssemblyInfoFilesAtPathWhenNotExistsAndEnsureAssemblyInf "AssemblyInfo." + fileExtension, PathHelper.Combine("src", "Project", "Properties", "VersionAssemblyInfo." + fileExtension) }; - var variables = this.variableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false); + var variables = this.variableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v?"), new TestEffectiveConfiguration(), false); using var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(this.log, this.fileSystem); assemblyInfoFileUpdater.Execute(variables, new AssemblyInfoContext(workingDir, true, assemblyInfoFiles.ToArray())); @@ -101,7 +101,7 @@ public void ShouldNotCreateAssemblyInfoFileWhenNotExistsAndNotEnsureAssemblyInfo var workingDir = Path.GetTempPath(); var assemblyInfoFile = "VersionAssemblyInfo." + fileExtension; var fullPath = PathHelper.Combine(workingDir, assemblyInfoFile); - var variables = this.variableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false); + var variables = this.variableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v?"), new TestEffectiveConfiguration(), false); using var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(this.log, this.fileSystem); assemblyInfoFileUpdater.Execute(variables, new AssemblyInfoContext(workingDir, false, assemblyInfoFile)); @@ -116,7 +116,7 @@ public void ShouldNotCreateAssemblyInfoFileForUnknownSourceCodeAndEnsureAssembly var workingDir = Path.GetTempPath(); const string assemblyInfoFile = "VersionAssemblyInfo.js"; var fullPath = PathHelper.Combine(workingDir, assemblyInfoFile); - var variables = this.variableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false); + var variables = this.variableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v?"), new TestEffectiveConfiguration(), false); using var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(this.log, this.fileSystem); assemblyInfoFileUpdater.Execute(variables, new AssemblyInfoContext(workingDir, true, assemblyInfoFile)); @@ -130,7 +130,7 @@ public void ShouldStartSearchFromWorkingDirectory() this.fileSystem = Substitute.For(); var workingDir = Path.GetTempPath(); var assemblyInfoFiles = Array.Empty(); - var variables = this.variableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false); + var variables = this.variableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v?"), new TestEffectiveConfiguration(), false); using var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(this.log, this.fileSystem); assemblyInfoFileUpdater.Execute(variables, new AssemblyInfoContext(workingDir, false, assemblyInfoFiles.ToArray())); diff --git a/src/GitVersion.Core.Tests/VersionConverters/ProjectFileUpdaterTests.cs b/src/GitVersion.Core.Tests/VersionConverters/ProjectFileUpdaterTests.cs index 5aab0aa92d..a3e089a909 100644 --- a/src/GitVersion.Core.Tests/VersionConverters/ProjectFileUpdaterTests.cs +++ b/src/GitVersion.Core.Tests/VersionConverters/ProjectFileUpdaterTests.cs @@ -154,7 +154,7 @@ public void CannotUpdateProjectFileWithoutAPropertyGroup(string xml) [Description(NoMonoDescription)] public void UpdateProjectXmlVersionElementWithStandardXmlInsertsElement(string xml) { - var variables = this.variableProvider.GetVariablesFor(SemanticVersion.Parse("2.0.0", "v"), new TestEffectiveConfiguration(), false); + var variables = this.variableProvider.GetVariablesFor(SemanticVersion.Parse("2.0.0", "v?"), new TestEffectiveConfiguration(), false); var xmlRoot = XElement.Parse(xml); variables.AssemblySemVer.ShouldNotBeNull(); ProjectFileUpdater.UpdateProjectVersionElement(xmlRoot, ProjectFileUpdater.AssemblyVersionElement, variables.AssemblySemVer); @@ -183,7 +183,7 @@ public void UpdateProjectXmlVersionElementWithStandardXmlInsertsElement(string x [Description(NoMonoDescription)] public void UpdateProjectXmlVersionElementWithStandardXmlModifiesElement(string xml) { - var variables = this.variableProvider.GetVariablesFor(SemanticVersion.Parse("2.0.0", "v"), new TestEffectiveConfiguration(), false); + var variables = this.variableProvider.GetVariablesFor(SemanticVersion.Parse("2.0.0", "v?"), new TestEffectiveConfiguration(), false); var xmlRoot = XElement.Parse(xml); variables.AssemblySemVer.ShouldNotBeNull(); ProjectFileUpdater.UpdateProjectVersionElement(xmlRoot, ProjectFileUpdater.AssemblyVersionElement, variables.AssemblySemVer); @@ -215,7 +215,7 @@ public void UpdateProjectXmlVersionElementWithStandardXmlModifiesElement(string [Description(NoMonoDescription)] public void UpdateProjectXmlVersionElementWithDuplicatePropertyGroupsModifiesLastElement(string xml) { - var variables = this.variableProvider.GetVariablesFor(SemanticVersion.Parse("2.0.0", "v"), new TestEffectiveConfiguration(), false); + var variables = this.variableProvider.GetVariablesFor(SemanticVersion.Parse("2.0.0", "v?"), new TestEffectiveConfiguration(), false); var xmlRoot = XElement.Parse(xml); variables.AssemblySemVer.ShouldNotBeNull(); ProjectFileUpdater.UpdateProjectVersionElement(xmlRoot, ProjectFileUpdater.AssemblyVersionElement, variables.AssemblySemVer); @@ -248,7 +248,7 @@ public void UpdateProjectXmlVersionElementWithDuplicatePropertyGroupsModifiesLas [Description(NoMonoDescription)] public void UpdateProjectXmlVersionElementWithMultipleVersionElementsLastOneIsModified(string xml) { - var variables = this.variableProvider.GetVariablesFor(SemanticVersion.Parse("2.0.0", "v"), new TestEffectiveConfiguration(), false); + var variables = this.variableProvider.GetVariablesFor(SemanticVersion.Parse("2.0.0", "v?"), new TestEffectiveConfiguration(), false); var xmlRoot = XElement.Parse(xml); variables.AssemblySemVer.ShouldNotBeNull(); ProjectFileUpdater.UpdateProjectVersionElement(xmlRoot, ProjectFileUpdater.AssemblyVersionElement, variables.AssemblySemVer); diff --git a/src/GitVersion.Core/Model/Configuration/Config.cs b/src/GitVersion.Core/Model/Configuration/Config.cs index f655cec39b..da29de5001 100644 --- a/src/GitVersion.Core/Model/Configuration/Config.cs +++ b/src/GitVersion.Core/Model/Configuration/Config.cs @@ -104,7 +104,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 a6814b5b0d..2ca58b2334 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.ConfigFileLocator.DefaultFileName = "GitVersion.yml" -> string! -const GitVersion.Model.Configuration.Config.DefaultTagPrefix = "[vV]" -> string! +const GitVersion.Model.Configuration.Config.DefaultTagPrefix = "[vV]?" -> string! const GitVersion.Model.Configuration.Config.DevelopBranchKey = "develop" -> string! const GitVersion.Model.Configuration.Config.DevelopBranchRegex = "^dev(elop)?(ment)?$" -> string! const GitVersion.Model.Configuration.Config.FeatureBranchKey = "feature" -> string! diff --git a/src/GitVersion.Core/VersionCalculation/SemanticVersioning/SemanticVersion.cs b/src/GitVersion.Core/VersionCalculation/SemanticVersioning/SemanticVersion.cs index a16317b618..27b240cc4d 100644 --- a/src/GitVersion.Core/VersionCalculation/SemanticVersioning/SemanticVersion.cs +++ b/src/GitVersion.Core/VersionCalculation/SemanticVersioning/SemanticVersion.cs @@ -138,7 +138,7 @@ public static SemanticVersion Parse(string version, string? tagPrefixRegex) public static bool TryParse(string version, string? tagPrefixRegex, [NotNullWhen(true)] out SemanticVersion? semanticVersion) { - var match = Regex.Match(version, $"^({tagPrefixRegex})?(?.*)$"); + var match = Regex.Match(version, $"^({tagPrefixRegex})(?.*)$"); if (!match.Success) {