Skip to content

Commit 99be2c3

Browse files
committed
fix(sonarcloud): Define a constant instead of using this literal 'pull-request' 7 times.
1 parent 2031196 commit 99be2c3

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/GitVersion.Configuration.Tests/Configuration/ConfigurationExtensionsTests.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace GitVersion.Core.Tests.Configuration;
77
[TestFixture]
88
public class ConfigurationExtensionsTests : TestBase
99
{
10+
private const string PullRequestBranch = "pull-request";
1011
[TestCase("release/2.0.0",
1112
"refs/heads/release/2.0.0", "release/2.0.0", "release/2.0.0",
1213
true, false, false, false, true)]
@@ -64,13 +65,13 @@ public void EnsureGetBranchSpecificLabelProcessesEnvironmentVariables()
6465

6566
var configuration = GitFlowConfigurationBuilder.New
6667
.WithoutBranches()
67-
.WithBranch("pull-request", builder => builder
68+
.WithBranch(PullRequestBranch, builder => builder
6869
.WithLabel("pr-{env:GITHUB_HEAD_REF}")
6970
.WithRegularExpression(@"^pull[/-]"))
7071
.Build();
7172

72-
var effectiveConfiguration = configuration.GetEffectiveConfiguration(ReferenceName.FromBranchName("pull-request"));
73-
var actual = effectiveConfiguration.GetBranchSpecificLabel(ReferenceName.FromBranchName("pull-request"), null, environment);
73+
var effectiveConfiguration = configuration.GetEffectiveConfiguration(ReferenceName.FromBranchName(PullRequestBranch));
74+
var actual = effectiveConfiguration.GetBranchSpecificLabel(ReferenceName.FromBranchName(PullRequestBranch), null, environment);
7475
actual.ShouldBe("pr-feature-branch");
7576
}
7677

@@ -82,13 +83,13 @@ public void EnsureGetBranchSpecificLabelProcessesEnvironmentVariablesWithFallbac
8283

8384
var configuration = GitFlowConfigurationBuilder.New
8485
.WithoutBranches()
85-
.WithBranch("pull-request", builder => builder
86+
.WithBranch(PullRequestBranch, builder => builder
8687
.WithLabel("pr-{env:GITHUB_HEAD_REF ?? \"unknown\"}")
8788
.WithRegularExpression(@"^pull[/-]"))
8889
.Build();
8990

90-
var effectiveConfiguration = configuration.GetEffectiveConfiguration(ReferenceName.FromBranchName("pull-request"));
91-
var actual = effectiveConfiguration.GetBranchSpecificLabel(ReferenceName.FromBranchName("pull-request"), null, environment);
91+
var effectiveConfiguration = configuration.GetEffectiveConfiguration(ReferenceName.FromBranchName(PullRequestBranch));
92+
var actual = effectiveConfiguration.GetBranchSpecificLabel(ReferenceName.FromBranchName(PullRequestBranch), null, environment);
9293
actual.ShouldBe("pr-unknown");
9394
}
9495

@@ -133,7 +134,7 @@ public void EnsureGetBranchSpecificLabelProcessesEnvironmentVariablesEvenWhenReg
133134

134135
var configuration = GitFlowConfigurationBuilder.New
135136
.WithoutBranches()
136-
.WithBranch("pull-request", builder => builder
137+
.WithBranch(PullRequestBranch, builder => builder
137138
.WithLabel("pr-{env:GITHUB_HEAD_REF}")
138139
.WithRegularExpression(@"^pull[/-]"))
139140
.WithBranch("feature", builder => builder

0 commit comments

Comments
 (0)