Skip to content

Commit 44883b3

Browse files
committed
Finalizing the configuration of GitFlow and GitHubFlow workflow and align with the Mainline version strategy
1 parent 7fc958b commit 44883b3

File tree

139 files changed

+27667
-734
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+27667
-734
lines changed

src/GitVersion.Configuration.Tests/Configuration/ConfigurationProviderTests.CanWriteOutEffectiveConfiguration.approved.txt

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ branches:
2525
prevent-increment:
2626
when-current-commit-tagged: false
2727
track-merge-target: true
28+
track-merge-message: true
2829
regex: ^dev(elop)?(ment)?$
29-
source-branches: []
30+
source-branches:
31+
- main
3032
is-source-branch-for: []
3133
tracks-release-branches: true
3234
is-release-branch: false
@@ -38,10 +40,9 @@ branches:
3840
prevent-increment:
3941
of-merged-branch: true
4042
track-merge-target: false
43+
track-merge-message: true
4144
regex: ^master$|^main$
42-
source-branches:
43-
- develop
44-
- release
45+
source-branches: []
4546
is-source-branch-for: []
4647
tracks-release-branches: false
4748
is-release-branch: false
@@ -50,17 +51,15 @@ branches:
5051
release:
5152
mode: ManualDeployment
5253
label: beta
53-
increment: None
54+
increment: Minor
5455
prevent-increment:
5556
of-merged-branch: true
5657
when-current-commit-tagged: false
5758
track-merge-target: false
5859
regex: ^releases?[/-](?<BranchName>.+)
5960
source-branches:
60-
- develop
6161
- main
6262
- support
63-
- release
6463
is-source-branch-for: []
6564
tracks-release-branches: false
6665
is-release-branch: true
@@ -70,23 +69,28 @@ branches:
7069
mode: ManualDeployment
7170
label: '{BranchName}'
7271
increment: Inherit
73-
prevent-increment: {}
72+
prevent-increment:
73+
when-current-commit-tagged: false
74+
track-merge-message: true
7475
regex: ^features?[/-](?<BranchName>.+)
7576
source-branches:
7677
- develop
7778
- main
7879
- release
79-
- feature
8080
- support
8181
- hotfix
8282
is-source-branch-for: []
83+
is-main-branch: false
8384
pre-release-weight: 30000
8485
pull-request:
8586
mode: ContinuousDelivery
8687
label: PullRequest
8788
increment: Inherit
88-
prevent-increment: {}
89+
prevent-increment:
90+
of-merged-branch: true
91+
when-current-commit-tagged: false
8992
label-number-pattern: '[/-](?<number>\d+)'
93+
track-merge-message: true
9094
regex: ^(pull|pull\-requests|pr)[/-]
9195
source-branches:
9296
- develop
@@ -105,12 +109,11 @@ branches:
105109
when-current-commit-tagged: false
106110
regex: ^hotfix(es)?[/-](?<BranchName>.+)
107111
source-branches:
108-
- release
109112
- main
110113
- support
111-
- hotfix
112114
is-source-branch-for: []
113115
is-release-branch: true
116+
is-main-branch: false
114117
pre-release-weight: 30000
115118
support:
116119
label: ''
@@ -130,7 +133,8 @@ branches:
130133
mode: ManualDeployment
131134
label: '{BranchName}'
132135
increment: Inherit
133-
prevent-increment: {}
136+
prevent-increment:
137+
when-current-commit-tagged: true
134138
regex: (?<BranchName>.+)
135139
source-branches:
136140
- main
@@ -141,6 +145,7 @@ branches:
141145
- hotfix
142146
- support
143147
is-source-branch-for: []
148+
is-main-branch: false
144149
ignore:
145150
sha: []
146151
mode: ContinuousDelivery

src/GitVersion.Configuration.Tests/Configuration/ConfigurationProviderTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ public void ShouldUseDefaultSourceBranchesWhenNotSpecifiedForDevelop()
316316
using var _ = this.fileSystem.SetupConfigFile(path: this.repoPath, text: text);
317317
var configuration = this.configurationProvider.ProvideForDirectory(this.repoPath);
318318

319-
configuration.Branches["develop"].SourceBranches.ShouldBe(new List<string>());
319+
configuration.Branches["develop"].SourceBranches.ShouldBe(["main"]);
320320
}
321321

322322
[Test]
@@ -348,7 +348,7 @@ public void ShouldUseDefaultSourceBranchesWhenNotSpecifiedForFeature()
348348
var configuration = this.configurationProvider.ProvideForDirectory(this.repoPath);
349349

350350
configuration.Branches["feature"].SourceBranches.ShouldBe(
351-
new List<string> { "develop", MainBranch, "release", "feature", "support", "hotfix" });
351+
["develop", MainBranch, "release", "support", "hotfix"]);
352352
}
353353

354354
[Test]

src/GitVersion.Configuration/BranchConfiguration.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,31 @@ public virtual IBranchConfiguration Inherit(IBranchConfiguration configuration)
107107
PreReleaseWeight = PreReleaseWeight ?? configuration.PreReleaseWeight
108108
};
109109
}
110+
111+
public virtual IBranchConfiguration Inherit(EffectiveConfiguration configuration)
112+
{
113+
configuration.NotNull();
114+
115+
return new BranchConfiguration(this)
116+
{
117+
Increment = Increment == IncrementStrategy.Inherit ? configuration.Increment : Increment,
118+
DeploymentMode = DeploymentMode ?? configuration.DeploymentMode,
119+
Label = Label ?? configuration.Label,
120+
PreventIncrement = new PreventIncrementConfiguration()
121+
{
122+
OfMergedBranch = PreventIncrement.OfMergedBranch ?? configuration.PreventIncrementOfMergedBranch,
123+
WhenBranchMerged = PreventIncrement.WhenBranchMerged ?? configuration.PreventIncrementWhenBranchMerged,
124+
WhenCurrentCommitTagged = PreventIncrement.WhenCurrentCommitTagged ?? configuration.PreventIncrementWhenCurrentCommitTagged
125+
},
126+
LabelNumberPattern = LabelNumberPattern ?? configuration.LabelNumberPattern,
127+
TrackMergeTarget = TrackMergeTarget ?? configuration.TrackMergeTarget,
128+
TrackMergeMessage = TrackMergeMessage ?? configuration.TrackMergeMessage,
129+
CommitMessageIncrementing = CommitMessageIncrementing ?? configuration.CommitMessageIncrementing,
130+
RegularExpression = RegularExpression ?? configuration.RegularExpression,
131+
TracksReleaseBranches = TracksReleaseBranches ?? configuration.TracksReleaseBranches,
132+
IsReleaseBranch = IsReleaseBranch ?? configuration.IsReleaseBranch,
133+
IsMainBranch = IsMainBranch ?? configuration.IsMainBranch,
134+
PreReleaseWeight = PreReleaseWeight ?? configuration.PreReleaseWeight
135+
};
136+
}
110137
}

src/GitVersion.Configuration/Builders/GitFlowConfigurationBuilder.cs

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,14 @@ private GitFlowConfigurationBuilder()
4545
{
4646
Increment = IncrementStrategy.Minor,
4747
RegularExpression = DevelopBranch.RegexPattern,
48-
SourceBranches = [],
48+
SourceBranches = [this.MainBranch.Name],
4949
Label = "alpha",
5050
PreventIncrement = new PreventIncrementConfiguration()
5151
{
5252
WhenCurrentCommitTagged = false
5353
},
5454
TrackMergeTarget = true,
55+
TrackMergeMessage = true,
5556
TracksReleaseBranches = true,
5657
IsMainBranch = false,
5758
IsReleaseBranch = false,
@@ -62,17 +63,14 @@ private GitFlowConfigurationBuilder()
6263
{
6364
Increment = IncrementStrategy.Patch,
6465
RegularExpression = MainBranch.RegexPattern,
65-
SourceBranches =
66-
[
67-
this.DevelopBranch.Name,
68-
this.ReleaseBranch.Name
69-
],
66+
SourceBranches = [],
7067
Label = string.Empty,
7168
PreventIncrement = new PreventIncrementConfiguration()
7269
{
7370
OfMergedBranch = true
7471
},
7572
TrackMergeTarget = false,
73+
TrackMergeMessage = true,
7674
TracksReleaseBranches = false,
7775
IsMainBranch = true,
7876
IsReleaseBranch = false,
@@ -81,15 +79,13 @@ private GitFlowConfigurationBuilder()
8179

8280
WithBranch(ReleaseBranch.Name).WithConfiguration(new BranchConfiguration
8381
{
84-
Increment = IncrementStrategy.None,
82+
Increment = IncrementStrategy.Minor,
8583
DeploymentMode = DeploymentMode.ManualDeployment,
8684
RegularExpression = ReleaseBranch.RegexPattern,
8785
SourceBranches =
8886
[
89-
this.DevelopBranch.Name,
9087
this.MainBranch.Name,
9188
this.SupportBranch.Name,
92-
this.ReleaseBranch.Name
9389
],
9490
Label = "beta",
9591
PreventIncrement = new PreventIncrementConfiguration()
@@ -114,11 +110,16 @@ private GitFlowConfigurationBuilder()
114110
this.DevelopBranch.Name,
115111
this.MainBranch.Name,
116112
this.ReleaseBranch.Name,
117-
this.FeatureBranch.Name,
118113
this.SupportBranch.Name,
119114
this.HotfixBranch.Name
120115
],
121116
Label = ConfigurationConstants.BranchNamePlaceholder,
117+
PreventIncrement = new PreventIncrementConfiguration()
118+
{
119+
WhenCurrentCommitTagged = false
120+
},
121+
TrackMergeMessage = true,
122+
IsMainBranch = false,
122123
PreReleaseWeight = 30000
123124
});
124125

@@ -137,7 +138,13 @@ private GitFlowConfigurationBuilder()
137138
this.HotfixBranch.Name
138139
],
139140
Label = "PullRequest",
141+
PreventIncrement = new PreventIncrementConfiguration()
142+
{
143+
OfMergedBranch = true,
144+
WhenCurrentCommitTagged = false
145+
},
140146
LabelNumberPattern = ConfigurationConstants.DefaultLabelNumberPattern,
147+
TrackMergeMessage = true,
141148
PreReleaseWeight = 30000
142149
});
143150

@@ -152,13 +159,12 @@ private GitFlowConfigurationBuilder()
152159
},
153160
SourceBranches =
154161
[
155-
this.ReleaseBranch.Name,
156162
this.MainBranch.Name,
157163
this.SupportBranch.Name,
158-
this.HotfixBranch.Name
159164
],
160165
Label = "beta",
161166
IsReleaseBranch = true,
167+
IsMainBranch = false,
162168
PreReleaseWeight = 30000
163169
});
164170

@@ -182,7 +188,6 @@ private GitFlowConfigurationBuilder()
182188
WithBranch(UnknownBranch.Name).WithConfiguration(new BranchConfiguration
183189
{
184190
RegularExpression = UnknownBranch.RegexPattern,
185-
Label = ConfigurationConstants.BranchNamePlaceholder,
186191
DeploymentMode = DeploymentMode.ManualDeployment,
187192
Increment = IncrementStrategy.Inherit,
188193
SourceBranches =
@@ -194,7 +199,13 @@ private GitFlowConfigurationBuilder()
194199
this.PullRequestBranch.Name,
195200
this.HotfixBranch.Name,
196201
this.SupportBranch.Name
197-
]
202+
],
203+
Label = ConfigurationConstants.BranchNamePlaceholder,
204+
PreventIncrement = new PreventIncrementConfiguration()
205+
{
206+
WhenCurrentCommitTagged = true
207+
},
208+
IsMainBranch = false,
198209
});
199210
}
200211
}

0 commit comments

Comments
 (0)