Skip to content

Commit e8176a6

Browse files
committed
Integrate code review suggestions.
1 parent e19c90a commit e8176a6

File tree

7 files changed

+49
-74
lines changed

7 files changed

+49
-74
lines changed

docs/input/docs/reference/configuration.md

+22-24
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,22 @@ strategies:
6161
- VersionInBranchName
6262
branches:
6363
develop:
64-
mode: ContinuousDelivery
64+
tracks-release-branches: true
65+
is-release-branch: false
66+
is-main-branch: false
67+
pre-release-weight: 0
6568
label: alpha
6669
increment: Minor
6770
prevent-increment-of-merged-branch-version: false
6871
track-merge-target: true
6972
regex: ^dev(elop)?(ment)?$
7073
source-branches: []
7174
is-source-branch-for: []
72-
tracks-release-branches: true
73-
is-release-branch: false
74-
is-main-branch: false
75-
pre-release-weight: 0
7675
main:
77-
mode: ContinuousDeployment
76+
tracks-release-branches: false
77+
is-release-branch: false
78+
is-main-branch: true
79+
pre-release-weight: 55000
7880
label: ''
7981
increment: Patch
8082
prevent-increment-of-merged-branch-version: true
@@ -84,11 +86,12 @@ branches:
8486
- develop
8587
- release
8688
is-source-branch-for: []
87-
tracks-release-branches: false
88-
is-release-branch: false
89-
is-main-branch: true
90-
pre-release-weight: 55000
9189
release:
90+
tracks-release-branches: false
91+
is-release-branch: true
92+
is-main-branch: false
93+
pre-release-weight: 30000
94+
mode: ManualDeployment
9295
label: beta
9396
increment: None
9497
prevent-increment-of-merged-branch-version: true
@@ -100,11 +103,8 @@ branches:
100103
- support
101104
- release
102105
is-source-branch-for: []
103-
tracks-release-branches: false
104-
is-release-branch: true
105-
is-main-branch: false
106-
pre-release-weight: 30000
107106
feature:
107+
pre-release-weight: 30000
108108
mode: ManualDeployment
109109
label: '{BranchName}'
110110
increment: Inherit
@@ -117,8 +117,8 @@ branches:
117117
- support
118118
- hotfix
119119
is-source-branch-for: []
120-
pre-release-weight: 30000
121120
pull-request:
121+
pre-release-weight: 30000
122122
mode: ContinuousDelivery
123123
label: PullRequest
124124
increment: Inherit
@@ -132,8 +132,9 @@ branches:
132132
- support
133133
- hotfix
134134
is-source-branch-for: []
135-
pre-release-weight: 30000
136135
hotfix:
136+
is-release-branch: true
137+
pre-release-weight: 30000
137138
mode: ManualDeployment
138139
label: beta
139140
increment: Inherit
@@ -144,9 +145,11 @@ branches:
144145
- support
145146
- hotfix
146147
is-source-branch-for: []
147-
is-release-branch: true
148-
pre-release-weight: 30000
149148
support:
149+
tracks-release-branches: false
150+
is-release-branch: false
151+
is-main-branch: true
152+
pre-release-weight: 55000
150153
label: ''
151154
increment: Patch
152155
prevent-increment-of-merged-branch-version: true
@@ -155,10 +158,6 @@ branches:
155158
source-branches:
156159
- main
157160
is-source-branch-for: []
158-
tracks-release-branches: false
159-
is-release-branch: false
160-
is-main-branch: true
161-
pre-release-weight: 55000
162161
unknown:
163162
mode: ManualDeployment
164163
label: '{BranchName}'
@@ -175,7 +174,7 @@ branches:
175174
is-source-branch-for: []
176175
ignore:
177176
sha: []
178-
mode: ManualDeployment
177+
mode: ContinuousDelivery
179178
label: '{BranchName}'
180179
increment: Inherit
181180
prevent-increment-of-merged-branch-version: false
@@ -188,7 +187,6 @@ is-source-branch-for: []
188187
tracks-release-branches: false
189188
is-release-branch: false
190189
is-main-branch: false
191-
192190
```
193191
194192
The details of the available options are as follows:

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

+2-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ strategies:
1919
- VersionInBranchName
2020
branches:
2121
develop:
22-
mode: ContinuousDelivery
2322
label: alpha
2423
increment: Minor
2524
prevent-increment-of-merged-branch-version: false
@@ -32,7 +31,6 @@ branches:
3231
is-main-branch: false
3332
pre-release-weight: 0
3433
main:
35-
mode: ContinuousDelivery
3634
label: ''
3735
increment: Patch
3836
prevent-increment-of-merged-branch-version: true
@@ -47,6 +45,7 @@ branches:
4745
is-main-branch: true
4846
pre-release-weight: 55000
4947
release:
48+
mode: ManualDeployment
5049
label: beta
5150
increment: None
5251
prevent-increment-of-merged-branch-version: true
@@ -105,7 +104,6 @@ branches:
105104
is-release-branch: true
106105
pre-release-weight: 30000
107106
support:
108-
mode: ContinuousDelivery
109107
label: ''
110108
increment: Patch
111109
prevent-increment-of-merged-branch-version: true
@@ -134,7 +132,7 @@ branches:
134132
is-source-branch-for: []
135133
ignore:
136134
sha: []
137-
mode: ManualDeployment
135+
mode: ContinuousDelivery
138136
label: '{BranchName}'
139137
increment: Inherit
140138
prevent-increment-of-merged-branch-version: false

src/GitVersion.Configuration/ConfigurationBuilderBase.cs

+9-16
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ internal abstract class ConfigurationBuilderBase<TConfigurationBuilder> : IConfi
2424
private string? commitDateFormat;
2525
private bool updateBuildNumber;
2626
private SemanticVersionFormat semanticVersionFormat;
27-
private VersionStrategies[] versionStrategies;
27+
private VersionStrategies versionStrategy;
2828
private Dictionary<string, string> mergeMessageFormats = new();
2929
private readonly List<IReadOnlyDictionary<object, object?>> overrides = new();
3030
private readonly Dictionary<string, BranchConfigurationBuilder> branchConfigurationBuilders = new();
@@ -200,20 +200,9 @@ public virtual TConfigurationBuilder WithSemanticVersionFormat(SemanticVersionFo
200200
return (TConfigurationBuilder)this;
201201
}
202202

203-
public virtual TConfigurationBuilder WithVersionStrategies(params VersionStrategies[] values)
204-
=> WithVersionStrategies((IEnumerable<VersionStrategies>)values);
205-
206-
public virtual TConfigurationBuilder WithVersionStrategies(IEnumerable<VersionStrategies> values)
203+
public virtual TConfigurationBuilder WithVersionStrategy(VersionStrategies value)
207204
{
208-
HashSet<VersionStrategies> versionStrategies = new();
209-
foreach (var versionStrategy in values)
210-
{
211-
versionStrategies.AddRange(
212-
Enum.GetValues<VersionStrategies>().Where(
213-
element => element != VersionStrategies.None && versionStrategy.HasFlag(element))
214-
);
215-
}
216-
this.versionStrategies = versionStrategies.ToArray();
205+
this.versionStrategy = value;
217206
return (TConfigurationBuilder)this;
218207
}
219208

@@ -339,7 +328,7 @@ public virtual TConfigurationBuilder WithConfiguration(IGitVersionConfiguration
339328
WithCommitDateFormat(value.CommitDateFormat);
340329
WithUpdateBuildNumber(value.UpdateBuildNumber);
341330
WithSemanticVersionFormat(value.SemanticVersionFormat);
342-
WithVersionStrategies(value.VersionStrategy);
331+
WithVersionStrategy(value.VersionStrategy);
343332
WithMergeMessageFormats(value.MergeMessageFormats);
344333
foreach (var (name, branchConfiguration) in value.Branches)
345334
{
@@ -377,6 +366,10 @@ public virtual IGitVersionConfiguration Build()
377366
branches.Add(name, (BranchConfiguration)branchConfigurationBuilder.Build());
378367
}
379368

369+
var versionStrategies = Enum.GetValues<VersionStrategies>()
370+
.Where(element => element != VersionStrategies.None && this.versionStrategy.HasFlag(element))
371+
.ToArray();
372+
380373
IGitVersionConfiguration configuration = new GitVersionConfiguration
381374
{
382375
AssemblyVersioningScheme = this.assemblyVersioningScheme,
@@ -396,7 +389,7 @@ public virtual IGitVersionConfiguration Build()
396389
CommitDateFormat = this.commitDateFormat,
397390
UpdateBuildNumber = this.updateBuildNumber,
398391
SemanticVersionFormat = this.semanticVersionFormat,
399-
VersionStrategies = this.versionStrategies,
392+
VersionStrategies = versionStrategies,
400393
Branches = branches,
401394
MergeMessageFormats = this.mergeMessageFormats,
402395
DeploymentMode = this.versioningMode,

src/GitVersion.Configuration/SupportedWorkflows/TrunkBased/v1.yml

+12-26
Original file line numberDiff line numberDiff line change
@@ -10,57 +10,43 @@ commit-date-format: yyyy-MM-dd
1010
merge-message-formats: {}
1111
update-build-number: true
1212
semantic-version-format: Strict
13-
strategies: [TrunkBased]
13+
strategies: [TrunkBased, ConfigNextVersion]
1414
branches:
1515
main:
16+
mode: ContinuousDeployment
1617
label: ''
1718
increment: Patch
1819
prevent-increment-of-merged-branch-version: true
1920
track-merge-target: false
2021
regex: ^master$|^main$
21-
source-branches:
22-
- release
22+
source-branches: []
2323
tracks-release-branches: false
2424
is-release-branch: false
2525
is-main-branch: true
2626
pre-release-weight: 55000
27-
release:
28-
label: beta
29-
increment: None
30-
prevent-increment-of-merged-branch-version: true
31-
track-merge-target: false
32-
regex: ^releases?[/-]
27+
feature:
28+
increment: Minor
29+
regex: ^features?[/-](?<BranchName>.+)
3330
source-branches:
3431
- main
35-
- release
36-
tracks-release-branches: false
37-
is-release-branch: true
38-
is-main-branch: false
3932
pre-release-weight: 30000
40-
feature:
41-
mode: ContinuousDelivery
42-
label: '{BranchName}'
43-
increment: Inherit
44-
regex: ^features?[/-](?<BranchName>.+)
33+
hotfix:
34+
increment: Patch
35+
regex: ^hotfix(es)?[/-](?<BranchName>.+)
4536
source-branches:
4637
- main
47-
- release
48-
- feature
4938
pre-release-weight: 30000
5039
pull-request:
51-
mode: ContinuousDelivery
40+
mode: ManualDeployment
5241
label: PullRequest
5342
increment: Inherit
5443
label-number-pattern: '[/-](?<number>\d+)'
5544
regex: ^(pull|pull\-requests|pr)[/-]
5645
source-branches:
5746
- main
58-
- release
59-
- feature
6047
pre-release-weight: 30000
6148
unknown:
62-
mode: ContinuousDelivery
63-
label: '{BranchName}'
49+
mode: ManualDeployment
6450
increment: Inherit
6551
regex: (?<BranchName>.*)
6652
source-branches:
@@ -70,7 +56,7 @@ branches:
7056
- pull-request
7157
ignore:
7258
sha: []
73-
mode: ContinuousDelivery
59+
mode: ManualDeployment
7460
label: '{BranchName}'
7561
increment: Inherit
7662
prevent-increment-of-merged-branch-version: false

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ private static GitHubFlowConfigurationBuilder GetConfigurationBuilder() => GitHu
2020
);
2121

2222
private static readonly IGitVersionConfiguration trunkBased = GetConfigurationBuilder()
23-
.WithVersionStrategies(VersionStrategies.TrunkBased)
23+
.WithVersionStrategy(VersionStrategies.TrunkBased)
2424
.WithBranch("main", _ => _.WithIsMainBranch(true).WithDeploymentMode(DeploymentMode.ContinuousDeployment))
2525
.WithBranch("feature", _ => _.WithIsMainBranch(false).WithDeploymentMode(DeploymentMode.ContinuousDelivery))
2626
.Build();

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace GitVersion.Core.Tests.IntegrationTests;
88
public class TrunkBasedDevelopmentScenarios : TestBase
99
{
1010
private static GitFlowConfigurationBuilder GetConfigurationBuilder() => GitFlowConfigurationBuilder.New
11-
.WithVersionStrategies(VersionStrategies.TrunkBased)
11+
.WithVersionStrategy(VersionStrategies.TrunkBased)
1212
.WithBranch("main", builder => builder
1313
.WithIsMainBranch(true).WithIncrement(IncrementStrategy.Patch)
1414
.WithDeploymentMode(DeploymentMode.ContinuousDeployment)
@@ -511,7 +511,7 @@ public void MergingFeatureBranchThatIncrementsMinorNumberIncrementsMinorVersionO
511511
public void VerifyIncrementConfigIsHonoured()
512512
{
513513
var minorIncrementConfig = GitFlowConfigurationBuilder.New
514-
.WithVersionStrategies(VersionStrategies.TrunkBased)
514+
.WithVersionStrategy(VersionStrategies.TrunkBased)
515515
.WithBranch("main", builder => builder
516516
.WithDeploymentMode(DeploymentMode.ContinuousDeployment)
517517
.WithIncrement(IncrementStrategy.None)

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public void CanUseConventionalCommitsToBumpVersion(string commitMessage, string
8686
.WithMinorVersionBumpMessage("^(feat)(\\([\\w\\s-]*\\))?:")
8787
// For future debugging of this regex: https://regex101.com/r/oFpqxA/2
8888
.WithPatchVersionBumpMessage("^(build|chore|ci|docs|fix|perf|refactor|revert|style|test)(\\([\\w\\s-]*\\))?:")
89-
.WithVersionStrategies(VersionStrategies.TrunkBased)
89+
.WithVersionStrategy(VersionStrategies.TrunkBased)
9090
.WithBranch("main", builder => builder.WithDeploymentMode(DeploymentMode.ContinuousDeployment))
9191
.Build();
9292

0 commit comments

Comments
 (0)