Skip to content

Commit 9ede034

Browse files
Casper Schmidt Wandahl-Liperarturcic
authored andcommitted
Add integration test and add underscore as a valid character in effective branch name
1 parent 22f9055 commit 9ede034

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/GitVersion.Core.Tests/IntegrationTests/FeatureBranchScenarios.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,15 @@ public void CanUseBranchNameOffAReleaseBranch()
183183
fixture.AssertFullSemver("0.3.0-PROJ-1.1+3", configuration);
184184
}
185185

186-
[TestCase("alpha", "JIRA-123", "alpha")]
187-
[TestCase($"alpha.{ConfigurationConstants.BranchNamePlaceholder}", "JIRA-123", "alpha.JIRA-123")]
188-
public void ShouldUseConfiguredTag(string tag, string featureName, string preReleaseTagName)
186+
[TestCase("alpha", "JIRA-123", "^features?[/-](?<BranchName>.+)", "alpha")]
187+
[TestCase($"alpha.{ConfigurationConstants.BranchNamePlaceholder}", "JIRA-123", "^features?[/-](?<BranchName>.+)", "alpha.JIRA-123")]
188+
[TestCase("{BranchName}-of-task-number-{TaskNumber}", "4711_this-is-a-feature", "^features?[/-](?<TaskNumber>\\d+)_(?<BranchName>.+)", "this-is-a-feature-of-task-number-4711")]
189+
public void ShouldUseConfiguredLabel(string label, string featureName, string regularExpression, string preReleaseLabelName)
189190
{
190191
var configuration = GitFlowConfigurationBuilder.New
191-
.WithBranch("feature", builder => builder.WithLabel(tag))
192+
.WithBranch("feature", builder => builder
193+
.WithLabel(label)
194+
.WithRegularExpression(regularExpression))
192195
.Build();
193196

194197
using var fixture = new EmptyRepositoryFixture();
@@ -197,7 +200,7 @@ public void ShouldUseConfiguredTag(string tag, string featureName, string preRel
197200
fixture.BranchTo(featureBranchName);
198201
fixture.Repository.MakeCommits(5);
199202

200-
var expectedFullSemVer = $"1.0.1-{preReleaseTagName}.1+5";
203+
var expectedFullSemVer = $"1.0.1-{preReleaseLabelName}.1+5";
201204
fixture.AssertFullSemver(expectedFullSemVer, configuration);
202205
}
203206

src/GitVersion.Core/Configuration/ConfigurationExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public static bool IsReleaseBranch(this IGitVersionConfiguration configuration,
7777

7878
if (!configuration.RegularExpression.IsNullOrWhiteSpace() && !effectiveBranchName.IsNullOrEmpty())
7979
{
80-
effectiveBranchName = effectiveBranchName.RegexReplace("[^a-zA-Z0-9-]", "-");
80+
effectiveBranchName = effectiveBranchName.RegexReplace("[^a-zA-Z0-9-_]", "-");
8181
var pattern = new Regex(configuration.RegularExpression, RegexOptions.IgnoreCase);
8282
var match = pattern.Match(effectiveBranchName);
8383
if (match.Success)

0 commit comments

Comments
 (0)