diff --git a/new-cli/GitVersion.Common/GitVersion.Common.csproj b/new-cli/GitVersion.Common/GitVersion.Common.csproj
index 96f23e8568..f224f9e121 100644
--- a/new-cli/GitVersion.Common/GitVersion.Common.csproj
+++ b/new-cli/GitVersion.Common/GitVersion.Common.csproj
@@ -7,6 +7,7 @@
+
diff --git a/src/GitVersion.App.Tests/ArgumentParserTests.cs b/src/GitVersion.App.Tests/ArgumentParserTests.cs
index d8456c7d12..b8650499c8 100644
--- a/src/GitVersion.App.Tests/ArgumentParserTests.cs
+++ b/src/GitVersion.App.Tests/ArgumentParserTests.cs
@@ -450,7 +450,7 @@ private static IEnumerable OverrideConfigWithSingleOptionTestData(
"tag-prefix=sample",
new GitVersionConfiguration
{
- TagPrefix = "sample"
+ TagPrefixPattern = "sample"
}
);
yield return new TestCaseData(
@@ -546,7 +546,7 @@ private static IEnumerable OverrideConfigWithMultipleOptionsTestDa
"/overrideconfig tag-prefix=sample /overrideconfig assembly-versioning-scheme=MajorMinor",
new GitVersionConfiguration
{
- TagPrefix = "sample",
+ TagPrefixPattern = "sample",
AssemblyVersioningScheme = AssemblyVersioningScheme.MajorMinor
}
);
@@ -554,7 +554,7 @@ private static IEnumerable OverrideConfigWithMultipleOptionsTestDa
"/overrideconfig tag-prefix=sample /overrideconfig assembly-versioning-format=\"{Major}.{Minor}.{Patch}.{env:CI_JOB_ID ?? 0}\"",
new GitVersionConfiguration
{
- TagPrefix = "sample",
+ TagPrefixPattern = "sample",
AssemblyVersioningFormat = "{Major}.{Minor}.{Patch}.{env:CI_JOB_ID ?? 0}"
}
);
@@ -562,7 +562,7 @@ private static IEnumerable OverrideConfigWithMultipleOptionsTestDa
"/overrideconfig tag-prefix=sample /overrideconfig assembly-versioning-format=\"{Major}.{Minor}.{Patch}.{env:CI_JOB_ID ?? 0}\" /overrideconfig update-build-number=true /overrideconfig assembly-versioning-scheme=MajorMinorPatchTag /overrideconfig mode=ContinuousDelivery /overrideconfig tag-pre-release-weight=4",
new GitVersionConfiguration
{
- TagPrefix = "sample",
+ TagPrefixPattern = "sample",
AssemblyVersioningFormat = "{Major}.{Minor}.{Patch}.{env:CI_JOB_ID ?? 0}",
UpdateBuildNumber = true,
AssemblyVersioningScheme = AssemblyVersioningScheme.MajorMinorPatchTag,
diff --git a/src/GitVersion.BuildAgents/Agents/AzurePipelines.cs b/src/GitVersion.BuildAgents/Agents/AzurePipelines.cs
index 0978007fde..31d44ea671 100644
--- a/src/GitVersion.BuildAgents/Agents/AzurePipelines.cs
+++ b/src/GitVersion.BuildAgents/Agents/AzurePipelines.cs
@@ -1,4 +1,3 @@
-using System.Text.RegularExpressions;
using GitVersion.Extensions;
using GitVersion.Logging;
using GitVersion.OutputVariables;
@@ -52,7 +51,7 @@ private static string ReplaceVariables(string buildNumberEnv, KeyValuePair buildNumberEnv,
- _ => buildNumberEnv.RegexReplace(pattern, replacement, RegexOptions.IgnoreCase)
+ _ => buildNumberEnv.RegexReplace(pattern, replacement)
};
}
}
diff --git a/src/GitVersion.Configuration.Tests/Configuration/ConfigurationProviderTests.cs b/src/GitVersion.Configuration.Tests/Configuration/ConfigurationProviderTests.cs
index a07d47d8c9..9ece53a3f5 100644
--- a/src/GitVersion.Configuration.Tests/Configuration/ConfigurationProviderTests.cs
+++ b/src/GitVersion.Configuration.Tests/Configuration/ConfigurationProviderTests.cs
@@ -246,7 +246,7 @@ public void CanReadDefaultDocument()
configuration.AssemblyInformationalFormat.ShouldBe(null);
configuration.Branches["develop"].Label.ShouldBe("alpha");
configuration.Branches["release"].Label.ShouldBe("beta");
- configuration.TagPrefix.ShouldBe(ConfigurationConstants.DefaultTagPrefix);
+ configuration.TagPrefixPattern.ShouldBe(RegexPatterns.Configuration.DefaultTagPrefixPattern);
configuration.NextVersion.ShouldBe(null);
}
@@ -361,7 +361,7 @@ public void ShouldNotOverrideAnythingWhenOverrideConfigIsEmpty()
var expectedConfig = GitFlowConfigurationBuilder.New
.WithNextVersion("1.2.3")
- .WithTagPrefix("custom-tag-prefix-from-yml")
+ .WithTagPrefixPattern("custom-tag-prefix-from-yml")
.Build();
var configuration = this.configurationProvider.ProvideForDirectory(this.repoPath);
@@ -370,7 +370,7 @@ public void ShouldNotOverrideAnythingWhenOverrideConfigIsEmpty()
configuration.AssemblyInformationalFormat.ShouldBe(expectedConfig.AssemblyInformationalFormat);
configuration.AssemblyVersioningFormat.ShouldBe(expectedConfig.AssemblyVersioningFormat);
configuration.AssemblyFileVersioningFormat.ShouldBe(expectedConfig.AssemblyFileVersioningFormat);
- configuration.TagPrefix.ShouldBe(expectedConfig.TagPrefix);
+ configuration.TagPrefixPattern.ShouldBe(expectedConfig.TagPrefixPattern);
configuration.NextVersion.ShouldBe(expectedConfig.NextVersion);
configuration.MajorVersionBumpMessage.ShouldBe(expectedConfig.MajorVersionBumpMessage);
configuration.MinorVersionBumpMessage.ShouldBe(expectedConfig.MinorVersionBumpMessage);
@@ -398,7 +398,7 @@ public void ShouldUseDefaultTagPrefixWhenNotSetInConfigFile()
using var _ = this.fileSystem.SetupConfigFile(path: this.repoPath, text: text);
var configuration = this.configurationProvider.ProvideForDirectory(this.repoPath);
- configuration.TagPrefix.ShouldBe(ConfigurationConstants.DefaultTagPrefix);
+ configuration.TagPrefixPattern.ShouldBe(RegexPatterns.Configuration.DefaultTagPrefixPattern);
}
[Test]
@@ -408,7 +408,7 @@ public void ShouldUseTagPrefixFromConfigFileWhenProvided()
using var _ = this.fileSystem.SetupConfigFile(path: this.repoPath, text: text);
var configuration = this.configurationProvider.ProvideForDirectory(this.repoPath);
- configuration.TagPrefix.ShouldBe("custom-tag-prefix-from-yml");
+ configuration.TagPrefixPattern.ShouldBe("custom-tag-prefix-from-yml");
}
[Test]
@@ -422,7 +422,7 @@ public void ShouldOverrideTagPrefixWithOverrideConfigValue([Values] bool tagPref
};
var configuration = this.configurationProvider.ProvideForDirectory(this.repoPath, overrideConfiguration);
- configuration.TagPrefix.ShouldBe("tag-prefix-from-override-configuration");
+ configuration.TagPrefixPattern.ShouldBe("tag-prefix-from-override-configuration");
}
[Test]
@@ -437,7 +437,7 @@ public void ShouldNotOverrideDefaultTagPrefixWhenNotSetInOverrideConfig()
var configuration = this.configurationProvider.ProvideForDirectory(this.repoPath, overrideConfiguration);
- configuration.TagPrefix.ShouldBe(ConfigurationConstants.DefaultTagPrefix);
+ configuration.TagPrefixPattern.ShouldBe(RegexPatterns.Configuration.DefaultTagPrefixPattern);
}
[Test]
@@ -451,7 +451,7 @@ public void ShouldNotOverrideTagPrefixFromConfigFileWhenNotSetInOverrideConfig()
};
var configuration = this.configurationProvider.ProvideForDirectory(this.repoPath, overrideConfiguration);
- configuration.TagPrefix.ShouldBe("custom-tag-prefix-from-yml");
+ configuration.TagPrefixPattern.ShouldBe("custom-tag-prefix-from-yml");
}
[Test]
@@ -465,6 +465,6 @@ public void ShouldOverrideTagPrefixFromConfigFileWhenSetInOverrideConfig()
};
var configuration = this.configurationProvider.ProvideForDirectory(this.repoPath, overrideConfiguration);
- configuration.TagPrefix.ShouldBe("custom-tag-prefix-from-console");
+ configuration.TagPrefixPattern.ShouldBe("custom-tag-prefix-from-console");
}
}
diff --git a/src/GitVersion.Configuration/BranchConfiguration.cs b/src/GitVersion.Configuration/BranchConfiguration.cs
index b49054a7d3..5f8cbd07bf 100644
--- a/src/GitVersion.Configuration/BranchConfiguration.cs
+++ b/src/GitVersion.Configuration/BranchConfiguration.cs
@@ -1,4 +1,5 @@
using GitVersion.Configuration.Attributes;
+using GitVersion.Core;
using GitVersion.Extensions;
using GitVersion.VersionCalculation;
@@ -26,8 +27,8 @@ internal record BranchConfiguration : IBranchConfiguration
public PreventIncrementConfiguration PreventIncrement { get; internal set; } = new();
[JsonPropertyName("label-number-pattern")]
- [JsonPropertyDescription($"The regular expression pattern to use to extract the number from the branch name. Defaults to '{ConfigurationConstants.DefaultLabelNumberPattern}'.")]
- [JsonPropertyDefault(ConfigurationConstants.DefaultLabelNumberPattern)]
+ [JsonPropertyDescription($"The regular expression pattern to use to extract the number from the branch name. Defaults to '{RegexPatterns.Configuration.DefaultLabelNumberPattern}'.")]
+ [JsonPropertyDefault(RegexPatterns.Configuration.DefaultLabelNumberPattern)]
[JsonPropertyFormat(Format.Regex)]
public string? LabelNumberPattern { get; internal set; }
diff --git a/src/GitVersion.Configuration/Builders/ConfigurationBuilderBase.cs b/src/GitVersion.Configuration/Builders/ConfigurationBuilderBase.cs
index 465b16c59c..80d6437579 100644
--- a/src/GitVersion.Configuration/Builders/ConfigurationBuilderBase.cs
+++ b/src/GitVersion.Configuration/Builders/ConfigurationBuilderBase.cs
@@ -1,3 +1,4 @@
+using GitVersion.Core;
using GitVersion.Extensions;
using GitVersion.Helpers;
using GitVersion.VersionCalculation;
@@ -47,49 +48,49 @@ internal abstract class ConfigurationBuilderBase : IConfi
protected readonly BranchMetaData MainBranch = new()
{
Name = ConfigurationConstants.MainBranchKey,
- RegexPattern = ConfigurationConstants.MainBranchRegex
+ RegexPattern = RegexPatterns.Configuration.MainBranchRegexPattern
};
protected readonly BranchMetaData DevelopBranch = new()
{
Name = ConfigurationConstants.DevelopBranchKey,
- RegexPattern = ConfigurationConstants.DevelopBranchRegex
+ RegexPattern = RegexPatterns.Configuration.DevelopBranchRegexPattern
};
protected readonly BranchMetaData ReleaseBranch = new()
{
Name = ConfigurationConstants.ReleaseBranchKey,
- RegexPattern = ConfigurationConstants.ReleaseBranchRegex
+ RegexPattern = RegexPatterns.Configuration.ReleaseBranchRegexPattern
};
protected readonly BranchMetaData FeatureBranch = new()
{
Name = ConfigurationConstants.FeatureBranchKey,
- RegexPattern = ConfigurationConstants.FeatureBranchRegex
+ RegexPattern = RegexPatterns.Configuration.FeatureBranchRegexPattern
};
protected readonly BranchMetaData PullRequestBranch = new()
{
Name = ConfigurationConstants.PullRequestBranchKey,
- RegexPattern = ConfigurationConstants.PullRequestBranchRegex
+ RegexPattern = RegexPatterns.Configuration.PullRequestBranchRegexPattern
};
protected readonly BranchMetaData HotfixBranch = new()
{
Name = ConfigurationConstants.HotfixBranchKey,
- RegexPattern = ConfigurationConstants.HotfixBranchRegex
+ RegexPattern = RegexPatterns.Configuration.HotfixBranchRegexPattern
};
protected readonly BranchMetaData SupportBranch = new()
{
Name = ConfigurationConstants.SupportBranchKey,
- RegexPattern = ConfigurationConstants.SupportBranchRegex
+ RegexPattern = RegexPatterns.Configuration.SupportBranchRegexPattern
};
protected readonly BranchMetaData UnknownBranch = new()
{
Name = ConfigurationConstants.UnknownBranchKey,
- RegexPattern = ConfigurationConstants.UnknownBranchRegex
+ RegexPattern = RegexPatterns.Configuration.UnknownBranchRegexPattern
};
protected ConfigurationBuilderBase()
@@ -130,7 +131,7 @@ public virtual TConfigurationBuilder WithAssemblyFileVersioningFormat(string? va
return (TConfigurationBuilder)this;
}
- public virtual TConfigurationBuilder WithTagPrefix(string? value)
+ public virtual TConfigurationBuilder WithTagPrefixPattern(string? value)
{
this.tagPrefix = value;
return (TConfigurationBuilder)this;
@@ -338,7 +339,7 @@ public virtual TConfigurationBuilder WithConfiguration(IGitVersionConfiguration
WithAssemblyInformationalFormat(value.AssemblyInformationalFormat);
WithAssemblyVersioningFormat(value.AssemblyVersioningFormat);
WithAssemblyFileVersioningFormat(value.AssemblyFileVersioningFormat);
- WithTagPrefix(value.TagPrefix);
+ WithTagPrefixPattern(value.TagPrefixPattern);
WithVersionInBranchPattern(value.VersionInBranchPattern);
WithNextVersion(value.NextVersion);
WithMajorVersionBumpMessage(value.MajorVersionBumpMessage);
@@ -397,7 +398,7 @@ public virtual IGitVersionConfiguration Build()
AssemblyInformationalFormat = this.assemblyInformationalFormat,
AssemblyVersioningFormat = this.assemblyVersioningFormat,
AssemblyFileVersioningFormat = this.assemblyFileVersioningFormat,
- TagPrefix = this.tagPrefix,
+ TagPrefixPattern = this.tagPrefix,
VersionInBranchPattern = this.versionInBranchPattern,
NextVersion = this.nextVersion,
MajorVersionBumpMessage = this.majorVersionBumpMessage,
diff --git a/src/GitVersion.Configuration/Builders/GitFlowConfigurationBuilder.cs b/src/GitVersion.Configuration/Builders/GitFlowConfigurationBuilder.cs
index b7ed9aff44..0122d54b8d 100644
--- a/src/GitVersion.Configuration/Builders/GitFlowConfigurationBuilder.cs
+++ b/src/GitVersion.Configuration/Builders/GitFlowConfigurationBuilder.cs
@@ -20,8 +20,8 @@ private GitFlowConfigurationBuilder()
PatchVersionBumpMessage = RegexPatterns.VersionCalculation.DefaultPatchPattern,
SemanticVersionFormat = ConfigurationConstants.DefaultSemanticVersionFormat,
VersionStrategies = ConfigurationConstants.DefaultVersionStrategies,
- TagPrefix = ConfigurationConstants.DefaultTagPrefix,
- VersionInBranchPattern = ConfigurationConstants.DefaultVersionInBranchPattern,
+ TagPrefixPattern = RegexPatterns.Configuration.DefaultTagPrefixPattern,
+ VersionInBranchPattern = RegexPatterns.Configuration.DefaultVersionInBranchPattern,
TagPreReleaseWeight = ConfigurationConstants.DefaultTagPreReleaseWeight,
UpdateBuildNumber = ConfigurationConstants.DefaultUpdateBuildNumber,
DeploymentMode = DeploymentMode.ContinuousDelivery,
@@ -145,7 +145,7 @@ private GitFlowConfigurationBuilder()
OfMergedBranch = true,
WhenCurrentCommitTagged = false
},
- LabelNumberPattern = ConfigurationConstants.DefaultLabelNumberPattern,
+ LabelNumberPattern = RegexPatterns.Configuration.DefaultLabelNumberPattern,
TrackMergeMessage = true,
PreReleaseWeight = 30000
});
diff --git a/src/GitVersion.Configuration/Builders/GitHubFlowConfigurationBuilder.cs b/src/GitVersion.Configuration/Builders/GitHubFlowConfigurationBuilder.cs
index 8af099bcdc..b31db0c152 100644
--- a/src/GitVersion.Configuration/Builders/GitHubFlowConfigurationBuilder.cs
+++ b/src/GitVersion.Configuration/Builders/GitHubFlowConfigurationBuilder.cs
@@ -20,8 +20,8 @@ private GitHubFlowConfigurationBuilder()
PatchVersionBumpMessage = RegexPatterns.VersionCalculation.DefaultPatchPattern,
SemanticVersionFormat = ConfigurationConstants.DefaultSemanticVersionFormat,
VersionStrategies = ConfigurationConstants.DefaultVersionStrategies,
- TagPrefix = ConfigurationConstants.DefaultTagPrefix,
- VersionInBranchPattern = ConfigurationConstants.DefaultVersionInBranchPattern,
+ TagPrefixPattern = RegexPatterns.Configuration.DefaultTagPrefixPattern,
+ VersionInBranchPattern = RegexPatterns.Configuration.DefaultVersionInBranchPattern,
TagPreReleaseWeight = ConfigurationConstants.DefaultTagPreReleaseWeight,
UpdateBuildNumber = ConfigurationConstants.DefaultUpdateBuildNumber,
DeploymentMode = DeploymentMode.ContinuousDelivery,
@@ -114,7 +114,7 @@ private GitHubFlowConfigurationBuilder()
OfMergedBranch = true,
WhenCurrentCommitTagged = false
},
- LabelNumberPattern = ConfigurationConstants.DefaultLabelNumberPattern,
+ LabelNumberPattern = RegexPatterns.Configuration.DefaultLabelNumberPattern,
RegularExpression = PullRequestBranch.RegexPattern,
SourceBranches =
[
diff --git a/src/GitVersion.Configuration/Builders/TrunkBasedConfigurationBuilder.cs b/src/GitVersion.Configuration/Builders/TrunkBasedConfigurationBuilder.cs
index c1fbcdf519..74ccd921e6 100644
--- a/src/GitVersion.Configuration/Builders/TrunkBasedConfigurationBuilder.cs
+++ b/src/GitVersion.Configuration/Builders/TrunkBasedConfigurationBuilder.cs
@@ -23,8 +23,8 @@ private TrunkBasedConfigurationBuilder()
VersionStrategies.ConfiguredNextVersion,
VersionStrategies.Mainline
],
- TagPrefix = ConfigurationConstants.DefaultTagPrefix,
- VersionInBranchPattern = ConfigurationConstants.DefaultVersionInBranchPattern,
+ TagPrefixPattern = RegexPatterns.Configuration.DefaultTagPrefixPattern,
+ VersionInBranchPattern = RegexPatterns.Configuration.DefaultVersionInBranchPattern,
TagPreReleaseWeight = ConfigurationConstants.DefaultTagPreReleaseWeight,
UpdateBuildNumber = ConfigurationConstants.DefaultUpdateBuildNumber,
DeploymentMode = DeploymentMode.ContinuousDelivery,
@@ -112,7 +112,7 @@ private TrunkBasedConfigurationBuilder()
OfMergedBranch = true,
WhenCurrentCommitTagged = false
},
- LabelNumberPattern = ConfigurationConstants.DefaultLabelNumberPattern,
+ LabelNumberPattern = RegexPatterns.Configuration.DefaultLabelNumberPattern,
RegularExpression = PullRequestBranch.RegexPattern,
SourceBranches =
[
diff --git a/src/GitVersion.Configuration/GitVersionConfiguration.cs b/src/GitVersion.Configuration/GitVersionConfiguration.cs
index ee6981920c..0a8c23e4d3 100644
--- a/src/GitVersion.Configuration/GitVersionConfiguration.cs
+++ b/src/GitVersion.Configuration/GitVersionConfiguration.cs
@@ -1,8 +1,6 @@
using System.Globalization;
-using System.Text.RegularExpressions;
using GitVersion.Configuration.Attributes;
using GitVersion.Core;
-using GitVersion.Extensions;
using GitVersion.VersionCalculation;
using static GitVersion.Configuration.ConfigurationConstants;
@@ -38,28 +36,17 @@ internal sealed record GitVersionConfiguration : BranchConfiguration, IGitVersio
public string? AssemblyFileVersioningFormat { get; internal set; }
[JsonPropertyName("tag-prefix")]
- [JsonPropertyDescription($"A regular expression which is used to trim Git tags before processing. Defaults to '{DefaultTagPrefix}'")]
- [JsonPropertyDefault(DefaultTagPrefix)]
+ [JsonPropertyDescription($"A regular expression which is used to trim Git tags before processing. Defaults to '{RegexPatterns.Configuration.DefaultTagPrefixPattern}'")]
+ [JsonPropertyDefault(RegexPatterns.Configuration.DefaultTagPrefixPattern)]
[JsonPropertyFormat(Format.Regex)]
- public string? TagPrefix { get; internal set; }
+ public string? TagPrefixPattern { get; internal set; }
[JsonPropertyName("version-in-branch-pattern")]
- [JsonPropertyDescription($"A regular expression which is used to determine the version number in the branch name or commit message (e.g., v1.0.0-LTS). Defaults to '{DefaultVersionInBranchPattern}'.")]
- [JsonPropertyDefault(DefaultVersionInBranchPattern)]
+ [JsonPropertyDescription($"A regular expression which is used to determine the version number in the branch name or commit message (e.g., v1.0.0-LTS). Defaults to '{RegexPatterns.Configuration.DefaultVersionInBranchPattern}'.")]
+ [JsonPropertyDefault(RegexPatterns.Configuration.DefaultVersionInBranchPattern)]
[JsonPropertyFormat(Format.Regex)]
public string? VersionInBranchPattern { get; internal set; }
- [JsonIgnore]
- public Regex VersionInBranchRegex => versionInBranchRegex ??= new(GetVersionInBranchPattern(), RegexOptions.Compiled);
- private Regex? versionInBranchRegex;
-
- private string GetVersionInBranchPattern()
- {
- var versionInBranchPattern = VersionInBranchPattern;
- if (versionInBranchPattern.IsNullOrEmpty()) versionInBranchPattern = DefaultVersionInBranchPattern;
- return $"^{versionInBranchPattern.TrimStart('^')}";
- }
-
[JsonPropertyName("next-version")]
[JsonPropertyDescription("Allows you to bump the next version explicitly. Useful for bumping main or a feature branch with breaking changes")]
public string? NextVersion
@@ -103,9 +90,7 @@ public string? NextVersion
[JsonPropertyName("commit-date-format")]
[JsonPropertyDescription($"The format to use when calculating the commit date. Defaults to '{DefaultCommitDateFormat}'. See [Standard Date and Time Format Strings](https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings) and [Custom Date and Time Format Strings](https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings).")]
[JsonPropertyDefault(DefaultCommitDateFormat)]
-#if NET7_0_OR_GREATER
- [System.Diagnostics.CodeAnalysis.StringSyntax("DateTimeFormat")] // See https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.codeanalysis.stringsyntaxattribute, https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.codeanalysis.stringsyntaxattribute.datetimeformat?view=net-7.0#system-diagnostics-codeanalysis-stringsyntaxattribute-datetimeformat
-#endif
+ [System.Diagnostics.CodeAnalysis.StringSyntax("DateTimeFormat")]
public string? CommitDateFormat { get; internal set; }
[JsonPropertyName("merge-message-formats")]
diff --git a/src/GitVersion.Core.Tests/Core/GitVersionExecutorTests.cs b/src/GitVersion.Core.Tests/Core/GitVersionExecutorTests.cs
index 6d02601c72..ebd81f0957 100644
--- a/src/GitVersion.Core.Tests/Core/GitVersionExecutorTests.cs
+++ b/src/GitVersion.Core.Tests/Core/GitVersionExecutorTests.cs
@@ -205,7 +205,7 @@ public void CacheFileExistsOnDiskWhenOverrideConfigIsSpecifiedVersionShouldBeDyn
var cacheDirectoryTimestamp = this.fileSystem.GetLastDirectoryWrite(cacheDirectory);
- var configuration = GitFlowConfigurationBuilder.New.WithTagPrefix("prefix").Build();
+ var configuration = GitFlowConfigurationBuilder.New.WithTagPrefixPattern("prefix").Build();
var overrideConfiguration = new ConfigurationHelper(configuration).Dictionary;
gitVersionOptions = new() { WorkingDirectory = fixture.RepositoryPath, ConfigurationInfo = { OverrideConfiguration = overrideConfiguration } };
diff --git a/src/GitVersion.Core.Tests/IntegrationTests/MainScenarios.cs b/src/GitVersion.Core.Tests/IntegrationTests/MainScenarios.cs
index 709263c825..9609853812 100644
--- a/src/GitVersion.Core.Tests/IntegrationTests/MainScenarios.cs
+++ b/src/GitVersion.Core.Tests/IntegrationTests/MainScenarios.cs
@@ -208,14 +208,14 @@ public void CanSpecifyTagPrefixes()
fixture.Repository.MakeATaggedCommit(taggedVersion);
fixture.Repository.MakeCommits(5);
- var configuration = GitFlowConfigurationBuilder.New.WithTagPrefix("version-").Build();
+ var configuration = GitFlowConfigurationBuilder.New.WithTagPrefixPattern("version-").Build();
fixture.AssertFullSemver("1.0.4-5", configuration);
}
[Test]
public void CanSpecifyTagPrefixesAsRegex()
{
- var configuration = GitFlowConfigurationBuilder.New.WithTagPrefix($"version-|{ConfigurationConstants.DefaultTagPrefix}").Build();
+ var configuration = GitFlowConfigurationBuilder.New.WithTagPrefixPattern($"version-|{RegexPatterns.Configuration.DefaultTagPrefixPattern}").Build();
using var fixture = new EmptyRepositoryFixture();
var taggedVersion = "v1.0.3";
fixture.Repository.MakeATaggedCommit(taggedVersion);
@@ -233,7 +233,7 @@ public void CanSpecifyTagPrefixesAsRegex()
[Test]
public void AreTagsNotAdheringToTagPrefixIgnored()
{
- var configuration = GitFlowConfigurationBuilder.New.WithTagPrefix("").Build();
+ var configuration = GitFlowConfigurationBuilder.New.WithTagPrefixPattern("").Build();
using var fixture = new EmptyRepositoryFixture();
var taggedVersion = "version-1.0.3";
fixture.Repository.MakeATaggedCommit(taggedVersion);
diff --git a/src/GitVersion.Core.Tests/IntegrationTests/OtherBranchScenarios.cs b/src/GitVersion.Core.Tests/IntegrationTests/OtherBranchScenarios.cs
index 597ac26ba2..8412d0b015 100644
--- a/src/GitVersion.Core.Tests/IntegrationTests/OtherBranchScenarios.cs
+++ b/src/GitVersion.Core.Tests/IntegrationTests/OtherBranchScenarios.cs
@@ -22,7 +22,7 @@ public void CanUseCommitMessagesToBumpVersion_TagsTakePriorityOnlyIfVersions(
string expectedVersionAfterNewCommit)
{
var configuration = GitFlowConfigurationBuilder.New
- .WithTagPrefix(tagPrefix)
+ .WithTagPrefixPattern(tagPrefix)
.Build();
using var fixture = new EmptyRepositoryFixture();
@@ -61,7 +61,7 @@ public void CanUseCommitMessagesToBumpVersion_TagsTakePriorityOnlyIfVersions(
[TestCase("prefix", "bar", "2.1.0-1", "2.0.0-bar.1+1", ExpectedResult = "2.0.0-bar.1+1")]
public string WhenTaggingACommitAsPreRelease(string tagPrefix, string? label, string tag, string expectedVersion)
{
- var configuration = GitFlowConfigurationBuilder.New.WithLabel(null).WithTagPrefix(tagPrefix)
+ var configuration = GitFlowConfigurationBuilder.New.WithLabel(null).WithTagPrefixPattern(tagPrefix)
.WithBranch("main", b => b.WithLabel(label).WithDeploymentMode(DeploymentMode.ManualDeployment))
.Build();
diff --git a/src/GitVersion.Core.Tests/MergeMessageTests.cs b/src/GitVersion.Core.Tests/MergeMessageTests.cs
index 546355d2b6..79d7590f39 100644
--- a/src/GitVersion.Core.Tests/MergeMessageTests.cs
+++ b/src/GitVersion.Core.Tests/MergeMessageTests.cs
@@ -35,7 +35,7 @@ public void EmptyTagPrefix(string? prefix)
{
// Arrange
const string message = "Updated some code.";
- var configuration = GitHubFlowConfigurationBuilder.New.WithTagPrefix(prefix).Build();
+ var configuration = GitHubFlowConfigurationBuilder.New.WithTagPrefixPattern(prefix).Build();
// Act
var sut = new MergeMessage(message, configuration);
diff --git a/src/GitVersion.Core.Tests/VersionCalculation/SemanticVersionTests.cs b/src/GitVersion.Core.Tests/VersionCalculation/SemanticVersionTests.cs
index 6a59b13317..ae8fdb55db 100644
--- a/src/GitVersion.Core.Tests/VersionCalculation/SemanticVersionTests.cs
+++ b/src/GitVersion.Core.Tests/VersionCalculation/SemanticVersionTests.cs
@@ -1,4 +1,3 @@
-using GitVersion.Configuration;
using GitVersion.Core.Tests.Helpers;
namespace GitVersion.Core.Tests;
@@ -23,9 +22,9 @@ public class SemanticVersionTests : TestBase
[TestCase("1.2.3+4.Branch.Foo", 1, 2, 3, "", null, 4, "Foo", null, null, null, null, SemanticVersionFormat.Strict)]
[TestCase("1.2.3+randomMetaData", 1, 2, 3, "", null, null, null, null, "randomMetaData", null, null, SemanticVersionFormat.Strict)]
[TestCase("1.2.3-beta.1+4.Sha.12234.Othershiz", 1, 2, 3, "beta", 1, 4, null, "12234", "Othershiz", null, null, SemanticVersionFormat.Strict)]
- [TestCase("1.2.3", 1, 2, 3, "", null, null, null, null, null, null, ConfigurationConstants.DefaultTagPrefix, SemanticVersionFormat.Strict)]
- [TestCase("v1.2.3", 1, 2, 3, "", null, null, null, null, null, "1.2.3", ConfigurationConstants.DefaultTagPrefix, SemanticVersionFormat.Strict)]
- [TestCase("V1.2.3", 1, 2, 3, "", null, null, null, null, null, "1.2.3", ConfigurationConstants.DefaultTagPrefix, SemanticVersionFormat.Strict)]
+ [TestCase("1.2.3", 1, 2, 3, "", null, null, null, null, null, null, RegexPatterns.Configuration.DefaultTagPrefixPattern, SemanticVersionFormat.Strict)]
+ [TestCase("v1.2.3", 1, 2, 3, "", null, null, null, null, null, "1.2.3", RegexPatterns.Configuration.DefaultTagPrefixPattern, SemanticVersionFormat.Strict)]
+ [TestCase("V1.2.3", 1, 2, 3, "", null, null, null, null, null, "1.2.3", RegexPatterns.Configuration.DefaultTagPrefixPattern, SemanticVersionFormat.Strict)]
[TestCase("version-1.2.3", 1, 2, 3, "", null, null, null, null, null, "1.2.3", "version-", SemanticVersionFormat.Strict)]
[TestCase("1.0.0-develop-20201007113711", 1, 0, 0, "develop-20201007113711", null, null, null, null, null, "1.0.0-develop-20201007113711", null, SemanticVersionFormat.Strict)]
[TestCase("20201007113711.658165168461351.64136516984163213-develop-20201007113711.98848747823+65416321321", 20201007113711, 658165168461351, 64136516984163213, "develop-20201007113711", 98848747823, 65416321321, null, null, null, "20201007113711.658165168461351.64136516984163213-develop-20201007113711.98848747823+65416321321", null, SemanticVersionFormat.Strict)]
@@ -63,7 +62,7 @@ public void ValidateVersionParsing(
[TestCase("someText")]
[TestCase("some-T-ext")]
- [TestCase("v.1.2.3", ConfigurationConstants.DefaultTagPrefix)]
+ [TestCase("v.1.2.3", RegexPatterns.Configuration.DefaultTagPrefixPattern)]
public void ValidateInvalidVersionParsing(string versionString, string? tagPrefixRegex = null) =>
Assert.That(SemanticVersion.TryParse(versionString, tagPrefixRegex, out _), Is.False, "TryParse Result");
diff --git a/src/GitVersion.Core/Configuration/ConfigurationConstants.cs b/src/GitVersion.Core/Configuration/ConfigurationConstants.cs
index f09f24f83d..f8774c93ba 100644
--- a/src/GitVersion.Core/Configuration/ConfigurationConstants.cs
+++ b/src/GitVersion.Core/Configuration/ConfigurationConstants.cs
@@ -22,14 +22,8 @@ internal static class ConfigurationConstants
VersionStrategies.VersionInBranchName
];
public const string DefaultAssemblyInformationalFormat = "{InformationalVersion}";
- //language=regexp
- public const string DefaultTagPrefix = "[vV]?";
- //language=regexp
- public const string DefaultVersionInBranchPattern = @"(?[vV]?\d+(\.\d+)?(\.\d+)?).*";
public const string DefaultCommitDateFormat = "yyyy-MM-dd";
public const string BranchNamePlaceholder = "{BranchName}";
- //language=regexp
- public const string DefaultLabelNumberPattern = @"[/-](?\d+)";
public const bool DefaultUpdateBuildNumber = true;
public const int DefaultTagPreReleaseWeight = 60000;
@@ -42,21 +36,4 @@ internal static class ConfigurationConstants
public const string HotfixBranchKey = "hotfix";
public const string SupportBranchKey = "support";
public const string UnknownBranchKey = "unknown";
-
- //language=regexp
- public const string MainBranchRegex = "^master$|^main$";
- //language=regexp
- public const string DevelopBranchRegex = "^dev(elop)?(ment)?$";
- //language=regexp
- public const string ReleaseBranchRegex = "^releases?[/-](?.+)";
- //language=regexp
- public const string FeatureBranchRegex = "^features?[/-](?.+)";
- //language=regexp
- public const string PullRequestBranchRegex = @"^(pull|pull\-requests|pr)[/-]";
- //language=regexp
- public const string HotfixBranchRegex = "^hotfix(es)?[/-](?.+)";
- //language=regexp
- public const string SupportBranchRegex = "^support[/-](?.+)";
- //language=regexp
- public const string UnknownBranchRegex = "(?.+)";
}
diff --git a/src/GitVersion.Core/Configuration/EffectiveConfiguration.cs b/src/GitVersion.Core/Configuration/EffectiveConfiguration.cs
index 9708f95329..c7514c34cc 100644
--- a/src/GitVersion.Core/Configuration/EffectiveConfiguration.cs
+++ b/src/GitVersion.Core/Configuration/EffectiveConfiguration.cs
@@ -1,4 +1,3 @@
-using System.Text.RegularExpressions;
using GitVersion.Extensions;
using GitVersion.VersionCalculation;
@@ -10,7 +9,9 @@ namespace GitVersion.Configuration;
///
public record EffectiveConfiguration
{
- public EffectiveConfiguration(IGitVersionConfiguration configuration, IBranchConfiguration branchConfiguration,
+ public EffectiveConfiguration(
+ IGitVersionConfiguration configuration,
+ IBranchConfiguration branchConfiguration,
EffectiveConfiguration? fallbackConfiguration = null)
{
configuration.NotNull();
@@ -50,8 +51,8 @@ public EffectiveConfiguration(IGitVersionConfiguration configuration, IBranchCon
AssemblyVersioningFormat = configuration.AssemblyVersioningFormat;
AssemblyFileVersioningFormat = configuration.AssemblyFileVersioningFormat;
DeploymentMode = branchConfiguration.DeploymentMode.Value;
- TagPrefix = configuration.TagPrefix;
- VersionInBranchRegex = configuration.VersionInBranchRegex;
+ TagPrefix = configuration.TagPrefixPattern;
+ VersionInBranchPattern = configuration.VersionInBranchPattern;
Label = branchConfiguration.Label;
NextVersion = configuration.NextVersion;
Increment = branchConfiguration.Increment;
@@ -90,16 +91,10 @@ public EffectiveConfiguration(IGitVersionConfiguration configuration, IBranchCon
public string? AssemblyVersioningFormat { get; }
public string? AssemblyFileVersioningFormat { get; }
- ///
- /// Git tag prefix
- ///
public string? TagPrefix { get; }
- public Regex VersionInBranchRegex { get; }
+ public string? VersionInBranchPattern { get; }
- ///
- /// Label to use when calculating SemVer
- ///
public string? Label { get; }
public string? NextVersion { get; }
diff --git a/src/GitVersion.Core/Configuration/IBranchConfiguration.cs b/src/GitVersion.Core/Configuration/IBranchConfiguration.cs
index 52d05a612f..cf81ef3dcc 100644
--- a/src/GitVersion.Core/Configuration/IBranchConfiguration.cs
+++ b/src/GitVersion.Core/Configuration/IBranchConfiguration.cs
@@ -1,4 +1,5 @@
-using System.Text.RegularExpressions;
+using GitVersion.Core;
+using GitVersion.Extensions;
using GitVersion.VersionCalculation;
namespace GitVersion.Configuration;
@@ -24,7 +25,15 @@ public interface IBranchConfiguration
public string? RegularExpression { get; }
public bool IsMatch(string branchName)
- => RegularExpression != null && Regex.IsMatch(branchName, RegularExpression, RegexOptions.IgnoreCase);
+ {
+ if (string.IsNullOrWhiteSpace(RegularExpression))
+ {
+ return false;
+ }
+
+ var regex = RegexPatterns.Cache.GetOrAdd(RegularExpression);
+ return regex.IsMatch(branchName);
+ }
IReadOnlyCollection SourceBranches { get; }
diff --git a/src/GitVersion.Core/Configuration/IGitVersionConfiguration.cs b/src/GitVersion.Core/Configuration/IGitVersionConfiguration.cs
index 60307b3cd1..1461d38034 100644
--- a/src/GitVersion.Core/Configuration/IGitVersionConfiguration.cs
+++ b/src/GitVersion.Core/Configuration/IGitVersionConfiguration.cs
@@ -1,4 +1,3 @@
-using System.Text.RegularExpressions;
using GitVersion.VersionCalculation;
namespace GitVersion.Configuration;
@@ -17,12 +16,10 @@ public interface IGitVersionConfiguration : IBranchConfiguration
string? AssemblyFileVersioningFormat { get; }
- string? TagPrefix { get; }
+ string? TagPrefixPattern { get; }
string? VersionInBranchPattern { get; }
- Regex VersionInBranchRegex { get; }
-
string? NextVersion { get; }
string? MajorVersionBumpMessage { get; }
diff --git a/src/GitVersion.Core/Configuration/ReferenceNameExtensions.cs b/src/GitVersion.Core/Configuration/ReferenceNameExtensions.cs
index dd05cab0f2..630d637746 100644
--- a/src/GitVersion.Core/Configuration/ReferenceNameExtensions.cs
+++ b/src/GitVersion.Core/Configuration/ReferenceNameExtensions.cs
@@ -1,14 +1,54 @@
+using GitVersion.Core;
+using GitVersion.Extensions;
using GitVersion.Git;
namespace GitVersion.Configuration;
public static class ReferenceNameExtensions
{
- public static bool TryGetSemanticVersion(
- this ReferenceName source, out (SemanticVersion Value, string? Name) result, IGitVersionConfiguration configuration)
- => source.TryGetSemanticVersion(out result, configuration.VersionInBranchRegex, configuration.TagPrefix, configuration.SemanticVersionFormat);
+ public static bool TryGetSemanticVersion(this ReferenceName source, out (SemanticVersion Value, string? Name) result, EffectiveConfiguration configuration)
+ => source.TryGetSemanticVersion(out result, configuration.VersionInBranchPattern, configuration.TagPrefix, configuration.SemanticVersionFormat);
- public static bool TryGetSemanticVersion(
- this ReferenceName source, out (SemanticVersion Value, string? Name) result, EffectiveConfiguration configuration)
- => source.TryGetSemanticVersion(out result, configuration.VersionInBranchRegex, configuration.TagPrefix, configuration.SemanticVersionFormat);
+ public static bool TryGetSemanticVersion(this ReferenceName source, out (SemanticVersion Value, string? Name) result, IGitVersionConfiguration configuration)
+ => source.TryGetSemanticVersion(out result, configuration.VersionInBranchPattern, configuration.TagPrefixPattern, configuration.SemanticVersionFormat);
+
+ private static bool TryGetSemanticVersion(this ReferenceName referenceName, out (SemanticVersion Value, string? Name) result,
+ string? versionPatternPattern,
+ string? tagPrefix,
+ SemanticVersionFormat format)
+ {
+ var versionPatternRegex = RegexPatterns.Cache.GetOrAdd(GetVersionInBranchPattern(versionPatternPattern));
+ result = default;
+
+ int length = 0;
+ foreach (var branchPart in referenceName.WithoutOrigin.Split(GetBranchSeparator()))
+ {
+ if (string.IsNullOrEmpty(branchPart)) return false;
+
+ var match = versionPatternRegex.Match(branchPart);
+ if (match.Success)
+ {
+ var versionPart = match.Groups["version"].Value;
+ if (SemanticVersion.TryParse(versionPart, tagPrefix, out var semanticVersion, format))
+ {
+ length += versionPart.Length;
+ var name = referenceName.WithoutOrigin[length..].Trim('-');
+ result = new(semanticVersion, name.Length == 0 ? null : name);
+ return true;
+ }
+ }
+
+ length += branchPart.Length + 1;
+ }
+
+ return false;
+
+ char GetBranchSeparator() => referenceName.WithoutOrigin.Contains('/') || !referenceName.WithoutOrigin.Contains('-') ? '/' : '-';
+
+ static string GetVersionInBranchPattern(string? versionInBranchPattern)
+ {
+ if (versionInBranchPattern.IsNullOrEmpty()) versionInBranchPattern = RegexPatterns.Configuration.DefaultVersionInBranchPattern;
+ return $"^{versionInBranchPattern.TrimStart('^')}";
+ }
+ }
}
diff --git a/src/GitVersion.Core/Core/GitVersionContextFactory.cs b/src/GitVersion.Core/Core/GitVersionContextFactory.cs
index d75bc4ab6b..537c6145b9 100644
--- a/src/GitVersion.Core/Core/GitVersionContextFactory.cs
+++ b/src/GitVersion.Core/Core/GitVersionContextFactory.cs
@@ -41,7 +41,7 @@ public GitVersionContext Create(GitVersionOptions gitVersionOptions)
}
bool isCurrentCommitTagged = this.taggedSemanticVersionRepository.GetTaggedSemanticVersions(
- tagPrefix: configuration.TagPrefix,
+ tagPrefix: configuration.TagPrefixPattern,
format: configuration.SemanticVersionFormat,
ignore: configuration.Ignore
).Contains(currentCommit);
diff --git a/src/GitVersion.Core/Core/MainlineBranchFinder.cs b/src/GitVersion.Core/Core/MainlineBranchFinder.cs
index 2e2ad2fe96..8f818cf303 100644
--- a/src/GitVersion.Core/Core/MainlineBranchFinder.cs
+++ b/src/GitVersion.Core/Core/MainlineBranchFinder.cs
@@ -1,6 +1,6 @@
-using System.Text.RegularExpressions;
using GitVersion.Common;
using GitVersion.Configuration;
+using GitVersion.Core;
using GitVersion.Extensions;
using GitVersion.Git;
using GitVersion.Logging;
@@ -47,10 +47,10 @@ public bool IsMainBranch(IBranchConfiguration value)
if (value.RegularExpression == null)
return false;
- var mainlineRegex = value.RegularExpression;
+ var regex = RegexPatterns.Cache.GetOrAdd(value.RegularExpression);
var branchName = this.branch.Name.WithoutOrigin;
- var match = Regex.IsMatch(branchName, mainlineRegex);
- this.log.Info($"'{mainlineRegex}' {(match ? "matches" : "does not match")} '{branchName}'.");
+ var match = regex.IsMatch(branchName);
+ this.log.Info($"'{value.RegularExpression}' {(match ? "matches" : "does not match")} '{branchName}'.");
return match;
}
}
diff --git a/src/GitVersion.Core/Core/RegexPatterns.cs b/src/GitVersion.Core/Core/RegexPatterns.cs
index 3b57dc5c4f..23f7b82d0a 100644
--- a/src/GitVersion.Core/Core/RegexPatterns.cs
+++ b/src/GitVersion.Core/Core/RegexPatterns.cs
@@ -1,61 +1,168 @@
+using System.Collections.Concurrent;
+using System.Diagnostics.CodeAnalysis;
using System.Text.RegularExpressions;
namespace GitVersion.Core;
internal static class RegexPatterns
{
+ private const RegexOptions Options = RegexOptions.IgnoreCase | RegexOptions.Compiled;
+
+ internal static readonly ConcurrentDictionary Cache = new();
+
+ static RegexPatterns()
+ {
+ Cache.TryAdd(Common.SwitchArgumentRegex.ToString(), Common.SwitchArgumentRegex);
+ Cache.TryAdd(Common.ObscurePasswordRegex.ToString(), Common.ObscurePasswordRegex);
+ Cache.TryAdd(Common.ExpandTokensRegex.ToString(), Common.ExpandTokensRegex);
+
+ Cache.TryAdd(Configuration.DefaultTagPrefixRegex.ToString(), Configuration.DefaultTagPrefixRegex);
+ Cache.TryAdd(Configuration.DefaultVersionInBranchRegex.ToString(), Configuration.DefaultVersionInBranchRegex);
+ Cache.TryAdd(Configuration.DefaultLabelNumberRegex.ToString(), Configuration.DefaultLabelNumberRegex);
+ Cache.TryAdd(Configuration.MainBranchRegex.ToString(), Configuration.MainBranchRegex);
+ Cache.TryAdd(Configuration.DevelopBranchRegex.ToString(), Configuration.DevelopBranchRegex);
+ Cache.TryAdd(Configuration.ReleaseBranchRegex.ToString(), Configuration.ReleaseBranchRegex);
+ Cache.TryAdd(Configuration.FeatureBranchRegex.ToString(), Configuration.FeatureBranchRegex);
+ Cache.TryAdd(Configuration.PullRequestBranchRegex.ToString(), Configuration.PullRequestBranchRegex);
+ Cache.TryAdd(Configuration.HotfixBranchRegex.ToString(), Configuration.HotfixBranchRegex);
+ Cache.TryAdd(Configuration.SupportBranchRegex.ToString(), Configuration.SupportBranchRegex);
+ Cache.TryAdd(Configuration.UnknownBranchRegex.ToString(), Configuration.UnknownBranchRegex);
+
+ Cache.TryAdd(MergeMessage.DefaultMergeMessageRegex.ToString(), MergeMessage.DefaultMergeMessageRegex);
+ Cache.TryAdd(MergeMessage.SmartGitMergeMessageRegex.ToString(), MergeMessage.SmartGitMergeMessageRegex);
+ Cache.TryAdd(MergeMessage.BitBucketPullMergeMessageRegex.ToString(), MergeMessage.BitBucketPullMergeMessageRegex);
+ Cache.TryAdd(MergeMessage.BitBucketPullv7MergeMessageRegex.ToString(), MergeMessage.BitBucketPullv7MergeMessageRegex);
+ Cache.TryAdd(MergeMessage.BitBucketCloudPullMergeMessageRegex.ToString(), MergeMessage.BitBucketCloudPullMergeMessageRegex);
+ Cache.TryAdd(MergeMessage.GitHubPullMergeMessageRegex.ToString(), MergeMessage.GitHubPullMergeMessageRegex);
+ Cache.TryAdd(MergeMessage.RemoteTrackingMergeMessageRegex.ToString(), MergeMessage.RemoteTrackingMergeMessageRegex);
+ Cache.TryAdd(MergeMessage.AzureDevOpsPullMergeMessageRegex.ToString(), MergeMessage.AzureDevOpsPullMergeMessageRegex);
+
+ Cache.TryAdd(Output.AssemblyVersionRegex.ToString(), Output.AssemblyVersionRegex);
+ Cache.TryAdd(Output.AssemblyInfoVersionRegex.ToString(), Output.AssemblyInfoVersionRegex);
+ Cache.TryAdd(Output.AssemblyFileVersionRegex.ToString(), Output.AssemblyFileVersionRegex);
+ Cache.TryAdd(Output.CsharpAssemblyAttributeRegex.ToString(), Output.CsharpAssemblyAttributeRegex);
+ Cache.TryAdd(Output.FsharpAssemblyAttributeRegex.ToString(), Output.FsharpAssemblyAttributeRegex);
+ Cache.TryAdd(Output.VisualBasicAssemblyAttributeRegex.ToString(), Output.VisualBasicAssemblyAttributeRegex);
+
+ Cache.TryAdd(VersionCalculation.DefaultMajorRegex.ToString(), VersionCalculation.DefaultMajorRegex);
+ Cache.TryAdd(VersionCalculation.DefaultMinorRegex.ToString(), VersionCalculation.DefaultMinorRegex);
+ Cache.TryAdd(VersionCalculation.DefaultPatchRegex.ToString(), VersionCalculation.DefaultPatchRegex);
+ Cache.TryAdd(VersionCalculation.DefaultNoBumpRegex.ToString(), VersionCalculation.DefaultNoBumpRegex);
+
+ Cache.TryAdd(SemanticVersion.ParseStrictRegex.ToString(), SemanticVersion.ParseStrictRegex);
+ Cache.TryAdd(SemanticVersion.ParseLooseRegex.ToString(), SemanticVersion.ParseLooseRegex);
+ Cache.TryAdd(SemanticVersion.ParseBuildMetaDataRegex.ToString(), SemanticVersion.ParseBuildMetaDataRegex);
+ Cache.TryAdd(SemanticVersion.FormatBuildMetaDataRegex.ToString(), SemanticVersion.FormatBuildMetaDataRegex);
+ Cache.TryAdd(SemanticVersion.ParsePreReleaseTagRegex.ToString(), SemanticVersion.ParsePreReleaseTagRegex);
+
+ Cache.TryAdd(AssemblyVersion.CSharp.TriviaRegex.ToString(), AssemblyVersion.CSharp.TriviaRegex);
+ Cache.TryAdd(AssemblyVersion.CSharp.AttributeRegex.ToString(), AssemblyVersion.CSharp.AttributeRegex);
+ Cache.TryAdd(AssemblyVersion.FSharp.TriviaRegex.ToString(), AssemblyVersion.FSharp.TriviaRegex);
+ Cache.TryAdd(AssemblyVersion.FSharp.AttributeRegex.ToString(), AssemblyVersion.FSharp.AttributeRegex);
+ Cache.TryAdd(AssemblyVersion.VisualBasic.TriviaRegex.ToString(), AssemblyVersion.VisualBasic.TriviaRegex);
+ Cache.TryAdd(AssemblyVersion.VisualBasic.AttributeRegex.ToString(), AssemblyVersion.VisualBasic.AttributeRegex);
+ }
+
internal static class Common
{
- public static Regex SwitchArgumentRegex { get; } = new(@"/\w+:", RegexOptions.Compiled);
- public static Regex ObscurePasswordRegex { get; } = new("(https?://)(.+)(:.+@)", RegexOptions.Compiled);
+ public static Regex SwitchArgumentRegex { get; } = new(@"/\w+:", Options);
+ public static Regex ObscurePasswordRegex { get; } = new("(https?://)(.+)(:.+@)", Options);
// This regex matches an expression to replace.
// - env:ENV name OR a member name
// - optional fallback value after " ?? "
// - the fallback value should be a quoted string, but simple unquoted text is allowed for back compat
- public static Regex ExpandTokensRegex { get; } = new("""{((env:(?\w+))|(?\w+))(\s+(\?\?)??\s+((?\w+)|"(?.*)"))??}""", RegexOptions.Compiled);
+ public static Regex ExpandTokensRegex { get; } = new("""{((env:(?\w+))|(?\w+))(\s+(\?\?)??\s+((?\w+)|"(?.*)"))??}""", Options);
+ }
+
+ internal static class Configuration
+ {
+ [StringSyntax(StringSyntaxAttribute.Regex)]
+ public const string DefaultTagPrefixPattern = "[vV]?";
+
+ [StringSyntax(StringSyntaxAttribute.Regex)]
+ public const string DefaultVersionInBranchPattern = @"(?[vV]?\d+(\.\d+)?(\.\d+)?).*";
+
+ [StringSyntax(StringSyntaxAttribute.Regex)]
+ public const string DefaultLabelNumberPattern = @"[/-](?\d+)";
+
+ [StringSyntax(StringSyntaxAttribute.Regex)]
+ public const string MainBranchRegexPattern = "^master$|^main$";
+
+ [StringSyntax(StringSyntaxAttribute.Regex)]
+ public const string DevelopBranchRegexPattern = "^dev(elop)?(ment)?$";
+
+ [StringSyntax(StringSyntaxAttribute.Regex)]
+ public const string ReleaseBranchRegexPattern = "^releases?[/-](?.+)";
+
+ [StringSyntax(StringSyntaxAttribute.Regex)]
+ public const string FeatureBranchRegexPattern = "^features?[/-](?.+)";
+
+ [StringSyntax(StringSyntaxAttribute.Regex)]
+ public const string PullRequestBranchRegexPattern = @"^(pull|pull\-requests|pr)[/-]";
+
+ [StringSyntax(StringSyntaxAttribute.Regex)]
+ public const string HotfixBranchRegexPattern = "^hotfix(es)?[/-](?.+)";
+
+ [StringSyntax(StringSyntaxAttribute.Regex)]
+ public const string SupportBranchRegexPattern = "^support[/-](?.+)";
+
+ [StringSyntax(StringSyntaxAttribute.Regex)]
+ public const string UnknownBranchRegexPattern = "(?.+)";
+
+ public static Regex DefaultTagPrefixRegex { get; } = new(DefaultTagPrefixPattern, Options);
+ public static Regex DefaultVersionInBranchRegex { get; } = new(DefaultVersionInBranchPattern, Options);
+ public static Regex DefaultLabelNumberRegex { get; } = new(DefaultLabelNumberPattern, Options);
+ public static Regex MainBranchRegex { get; } = new(MainBranchRegexPattern, Options);
+ public static Regex DevelopBranchRegex { get; } = new(DevelopBranchRegexPattern, Options);
+ public static Regex ReleaseBranchRegex { get; } = new(ReleaseBranchRegexPattern, Options);
+ public static Regex FeatureBranchRegex { get; } = new(FeatureBranchRegexPattern, Options);
+ public static Regex PullRequestBranchRegex { get; } = new(PullRequestBranchRegexPattern, Options);
+ public static Regex HotfixBranchRegex { get; } = new(HotfixBranchRegexPattern, Options);
+ public static Regex SupportBranchRegex { get; } = new(SupportBranchRegexPattern, Options);
+ public static Regex UnknownBranchRegex { get; } = new(UnknownBranchRegexPattern, Options);
}
internal static class MergeMessage
{
- public static Regex DefaultMergeMessageRegex { get; } = new(@"^Merge (branch|tag) '(?[^']*)'(?: into (?[^\s]*))*", RegexOptions.IgnoreCase | RegexOptions.Compiled);
- public static Regex SmartGitMergeMessageRegex { get; } = new(@"^Finish (?[^\s]*)(?: into (?[^\s]*))*", RegexOptions.IgnoreCase | RegexOptions.Compiled);
- public static Regex BitBucketPullMergeMessageRegex { get; } = new(@"^Merge pull request #(?\d+) (from|in) (?