Skip to content

Commit 07bf7e1

Browse files
committed
fix master regex after adding main, add/modify tests to cover that change
1 parent 05377a4 commit 07bf7e1

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

docs/input/docs/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ upgrade.
283283
```yaml
284284
branches:
285285
master:
286-
regex: ^master|main$
286+
regex: ^master$|^main$"
287287
mode: ContinuousDelivery
288288
tag: ''
289289
increment: Patch

src/GitVersionCore.Tests/Configuration/ConfigProviderTests.CanWriteOutEffectiveConfiguration.approved.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ branches:
3131
increment: Patch
3232
prevent-increment-of-merged-branch-version: true
3333
track-merge-target: false
34-
regex: ^master|main$
34+
regex: ^master$|^main$"
3535
source-branches:
3636
- develop
3737
- release

src/GitVersionCore.Tests/IntegrationTests/OtherScenarios.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,6 @@ public void AllowHavingVariantsStartingWithMaster()
6060
[Test]
6161
public void AllowHavingMainInsteadOfMaster()
6262
{
63-
var config = new Config();
64-
config.Branches.Add("master", new BranchConfig
65-
{
66-
Regex = "main",
67-
VersioningMode = VersioningMode.ContinuousDelivery,
68-
Tag = "useBranchName",
69-
Increment = IncrementStrategy.Patch,
70-
PreventIncrementOfMergedBranchVersion = true,
71-
TrackMergeTarget = false,
72-
SourceBranches = new HashSet<string>()
73-
});
74-
7563
using var fixture = new EmptyRepositoryFixture();
7664
fixture.Repository.MakeACommit();
7765
Commands.Checkout(fixture.Repository, fixture.Repository.CreateBranch("develop"));
@@ -81,6 +69,18 @@ public void AllowHavingMainInsteadOfMaster()
8169
fixture.AssertFullSemver("0.1.0-1+0", config);
8270
}
8371

72+
[Test]
73+
public void AllowHavingVariantsStartingWithMain()
74+
{
75+
using var fixture = new EmptyRepositoryFixture();
76+
fixture.Repository.MakeACommit();
77+
fixture.Repository.MakeATaggedCommit("1.0.0");
78+
fixture.Repository.MakeACommit();
79+
Commands.Checkout(fixture.Repository, fixture.Repository.CreateBranch("mainfix"));
80+
81+
fixture.AssertFullSemver("1.0.1-mainfix.1+1");
82+
}
83+
8484
[Test]
8585
public void DoNotBlowUpWhenDevelopAndFeatureBranchPointAtSameCommit()
8686
{

src/GitVersionCore/Model/Configuration/Config.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public override string ToString()
115115
public const string HotfixBranchRegex = "^hotfix(es)?[/-]";
116116
public const string SupportBranchRegex = "^support[/-]";
117117
public const string DevelopBranchRegex = "^dev(elop)?(ment)?$";
118-
public const string MasterBranchRegex = "^master|main$";
118+
public const string MasterBranchRegex = "^master$|^main$";
119119
public const string MasterBranchKey = "master";
120120
public const string ReleaseBranchKey = "release";
121121
public const string FeatureBranchKey = "feature";

0 commit comments

Comments
 (0)