Skip to content

Commit 97f4ca5

Browse files
committed
- Integrate the fallback branch configuration with all branch related properties in the root configuration.
- Create a new configuration section with name unknown to ensure the unknown branch configuration. - The way how the configuration (file, parameter) will be merged with the build-in gitflow configuration has been changed.
1 parent 7908a79 commit 97f4ca5

File tree

70 files changed

+1459
-1593
lines changed

Some content is hidden

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

70 files changed

+1459
-1593
lines changed

BREAKING_CHANGES.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,22 @@
66
* Instead of having a single effective configuration, we now have one effective configuration per branch where the increment strategy is not set to `inherit`.
77
* The new implementation of the branch configuration inheritance affects per default only the pull-requests, hotfix and feature branches. In this case the next version will be generated like the child branch is not existing and the commits have been made on the source branch.
88
* The following example illustrates this behavior. On the feature branch the semantic version `1.1.0-just-a-test.1+2` will now be generated instead of version `1.0.0-just-a-test.1+3` previously:
9-
```
9+
```
1010
* 1f1cfb4 52 minutes ago (HEAD -> feature/just-a-test)
11-
* 1f9654d 54 minutes ago (release/1.1.0)
12-
* be72411 56 minutes ago (develop)
13-
* 14800ff 58 minutes ago (tag: 1.0.0, main)
14-
```
11+
* 1f9654d 54 minutes ago (release/1.1.0)
12+
* be72411 56 minutes ago (develop)
13+
* 14800ff 58 minutes ago (tag: 1.0.0, main)
14+
```
15+
* A new `unknown` branch magic string has been introduced to give the user the possibility to specify the branch configuration for a branch which is not known. A branch is not known if only the regular expression of the branch configuration with the name `unknown` is matching. Please notice that this branch configuration behaves like any other branch configurations.
16+
* Additional `fallback` branch configuration properties have been introduced at the root to define base properties which will be inherit to the branch configurations. That means if no other branch configuration in the inheritance line defines the given property the fallback property applies. Notice that the inheritance tree can be controlled using the increment strategy property in the branch configuration section.
17+
* The following example illustrates this behavior. The hotfix branch configuration overrides the main branch configuration and the result overrides the fallback branch configuration.
18+
```
19+
* 1f1cfb4 52 minutes ago (HEAD -> hotfix/just-a-test)
20+
* 14800ff 58 minutes ago (tag: 1.0.0, main)
21+
```
22+
* When overriding the configuration with e.g. GitVersion.yaml the software distinguishes between properties who are not existent and properties who are `null`. This is especially important if the user wants to define branch related configuration which are marked with `increment` strategy `Inherit`.
23+
* Following root configuration properties have been removed:
24+
* continuous-delivery-fallback-tag
1525
1626
## v5.0.0
1727

docs/input/docs/reference/configuration.md

Lines changed: 121 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,134 @@ created. Modify this to suit your needs.
4040
The global configuration looks like this:
4141

4242
```yaml
43-
next-version: 1.0
4443
assembly-versioning-scheme: MajorMinorPatch
4544
assembly-file-versioning-scheme: MajorMinorPatch
46-
assembly-informational-format: '{InformationalVersion}'
47-
mode: ContinuousDelivery
48-
increment: Inherit
49-
continuous-delivery-fallback-label: ci
50-
label-prefix: '[vV]'
45+
label-prefix: '[vV]?'
5146
major-version-bump-message: '\+semver:\s?(breaking|major)'
5247
minor-version-bump-message: '\+semver:\s?(feature|minor)'
5348
patch-version-bump-message: '\+semver:\s?(fix|patch)'
5449
no-bump-message: '\+semver:\s?(none|skip)'
5550
label-pre-release-weight: 60000
56-
commit-message-incrementing: Enabled
51+
branches:
52+
develop:
53+
mode: ContinuousDeployment
54+
label: alpha
55+
increment: Minor
56+
prevent-increment-of-merged-branch-version: false
57+
track-merge-target: true
58+
regex: ^dev(elop)?(ment)?$
59+
source-branches: []
60+
tracks-release-branches: true
61+
is-release-branch: false
62+
is-mainline: false
63+
pre-release-weight: 0
64+
main:
65+
label: ''
66+
increment: Patch
67+
prevent-increment-of-merged-branch-version: true
68+
track-merge-target: false
69+
regex: ^master$|^main$
70+
source-branches:
71+
- develop
72+
- release
73+
tracks-release-branches: false
74+
is-release-branch: false
75+
is-mainline: true
76+
pre-release-weight: 55000
77+
release:
78+
label: beta
79+
increment: None
80+
prevent-increment-of-merged-branch-version: true
81+
track-merge-target: false
82+
regex: ^releases?[/-]
83+
source-branches:
84+
- develop
85+
- main
86+
- support
87+
- release
88+
tracks-release-branches: false
89+
is-release-branch: true
90+
is-mainline: false
91+
pre-release-weight: 30000
92+
feature:
93+
mode: ContinuousDelivery
94+
label: '{BranchName}'
95+
increment: Inherit
96+
regex: ^features?[/-]
97+
source-branches:
98+
- develop
99+
- main
100+
- release
101+
- feature
102+
- support
103+
- hotfix
104+
pre-release-weight: 30000
105+
pull-request:
106+
mode: ContinuousDelivery
107+
label: PullRequest
108+
increment: Inherit
109+
label-number-pattern: '[/-](?<number>\d+)'
110+
regex: ^(pull|pull\-requests|pr)[/-]
111+
source-branches:
112+
- develop
113+
- main
114+
- release
115+
- feature
116+
- support
117+
- hotfix
118+
pre-release-weight: 30000
119+
hotfix:
120+
mode: ContinuousDelivery
121+
label: beta
122+
increment: Inherit
123+
regex: ^hotfix(es)?[/-]
124+
source-branches:
125+
- release
126+
- main
127+
- support
128+
- hotfix
129+
pre-release-weight: 30000
130+
support:
131+
label: ''
132+
increment: Patch
133+
prevent-increment-of-merged-branch-version: true
134+
track-merge-target: false
135+
regex: ^support[/-]
136+
source-branches:
137+
- main
138+
tracks-release-branches: false
139+
is-release-branch: false
140+
is-mainline: true
141+
pre-release-weight: 55000
142+
unknown:
143+
mode: ContinuousDelivery
144+
label: '{BranchName}'
145+
increment: Inherit
146+
regex: .*
147+
source-branches:
148+
- main
149+
- develop
150+
- release
151+
- feature
152+
- pull-request
153+
- hotfix
154+
- support
57155
ignore:
58156
sha: []
59-
commits-before: yyyy-MM-ddTHH:mm:ss
157+
commit-date-format: yyyy-MM-dd
60158
merge-message-formats: {}
61159
update-build-number: true
160+
mode: ContinuousDelivery
161+
label: '{BranchName}'
162+
increment: Inherit
163+
prevent-increment-of-merged-branch-version: false
164+
track-merge-target: false
165+
commit-message-incrementing: Enabled
166+
regex: ''
167+
tracks-release-branches: false
168+
is-release-branch: false
169+
is-mainline: false
170+
62171
```
63172
64173
The details of the available options are as follows:
@@ -142,25 +251,6 @@ for [increment](#increment),
142251
[prevent-increment-of-merged-branch-version](#prevent-increment-of-merged-branch-version)
143252
and [tracks-release-branches](#tracks-release-branches).
144253

145-
### continuous-delivery-fallback-label
146-
147-
When using `mode: ContinuousDeployment`, the value specified in
148-
`continuous-delivery-fallback-label` will be used as the pre-release label for
149-
branches which do not have one specified. Default set to `ci`.
150-
151-
Just to clarify: For a build name without `...-ci-<buildnumber>` or in other
152-
words without a `PreReleaseTag` (ergo `"PreReleaseTag":""` in GitVersion's JSON output)
153-
at the end you would need to set `continuous-delivery-fallback-label` to an empty
154-
string (`''`):
155-
156-
```yaml
157-
mode: ContinuousDeployment
158-
continuous-delivery-fallback-label: ''
159-
...
160-
```
161-
162-
Doing so can be helpful if you use your `main` branch as a `release` branch.
163-
164254
### label-prefix
165255

166256
A regex which is used to trim Git tags before processing (e.g., v1.0.0). Default
@@ -200,7 +290,7 @@ The pre-release weight in case of tagged commits. If the value is not set in the
200290
configuration, a default weight of 60000 is used instead. If the
201291
`WeightedPreReleaseNumber` [variable][variables] is 0 and this parameter is set,
202292
its value is used. This helps if your branching model is GitFlow and the last
203-
release build, which is often tagged, can utilise this parameter to produce a
293+
release build, which is often tagged, can utilize this parameter to produce a
204294
monotonically increasing build number.
205295

206296
### commit-message-incrementing
@@ -441,7 +531,7 @@ Without this configuration value you would have to do:
441531
```yaml
442532
branches:
443533
unstable:
444-
regex: ...
534+
regex:
445535
feature:
446536
source-branches: ['unstable', 'develop', 'feature', 'hotfix', 'support']
447537
release:
@@ -539,9 +629,9 @@ is set, it would be added to the `PreReleaseNumber` to get a final
539629
`pre-release-weight` will be used in the calculation. Related Issues [1145][1145]
540630
and [1366][1366].
541631

542-
### semver-format
632+
### semantic-version-format
543633

544-
Specifies the semver format that is used when parsing the string.
634+
Specifies the semantic version format that is used when parsing the string.
545635
Can be `Strict` - using the [regex](https://regex101.com/r/Ly7O1x/3/)
546636
or `Loose` the old way of parsing. The default if not specified is `Strict`
547637
Example of invalid `Strict`, but valid `Loose`

docs/input/docs/usage/cli/arguments.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ Following options are supported:
117117
5. `assembly-versioning-scheme`
118118
7. `commit-date-format`
119119
8. `commit-message-incrementing`
120-
10. `continuous-delivery-fallback-label`
120+
10. `label`
121121
11. `increment`
122122
13. `major-version-bump-message`
123123
14. `minor-version-bump-message`

src/GitVersion.App.Tests/ArgumentParserTests.cs

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -386,30 +386,15 @@ private static IEnumerable<TestCaseData> OverrideconfigWithInvalidOptionTestData
386386
{
387387
ExpectedResult = "Could not parse /overrideconfig option: unknown-option=25. Unsupported 'key'."
388388
};
389-
yield return new TestCaseData("update-build-number=1")
390-
{
391-
ExpectedResult = "Could not parse /overrideconfig option: update-build-number=1. Ensure that 'value' is 'true' or 'false'."
392-
};
393-
yield return new TestCaseData("label-pre-release-weight=invalid-value")
394-
{
395-
ExpectedResult = "Could not parse /overrideconfig option: label-pre-release-weight=invalid-value. Ensure that 'value' is valid integer number."
396-
};
397-
yield return new TestCaseData("assembly-versioning-scheme=WrongEnumValue")
398-
{
399-
ExpectedResult = $"Could not parse /overrideconfig option: assembly-versioning-scheme=WrongEnumValue. Ensure that 'value' is valid for specified 'key' enumeration: {System.Environment.NewLine}" +
400-
$"MajorMinorPatchTag{System.Environment.NewLine}" +
401-
$"MajorMinorPatch{System.Environment.NewLine}" +
402-
$"MajorMinor{System.Environment.NewLine}" +
403-
$"Major{System.Environment.NewLine}" +
404-
$"None{System.Environment.NewLine}"
405-
};
406389
}
407390

408391
[TestCaseSource(nameof(OverrideConfigWithSingleOptionTestData))]
409392
public void OverrideConfigWithSingleOptions(string options, GitVersionConfiguration expected)
410393
{
411394
var arguments = this.argumentParser.ParseArguments($"/overrideconfig {options}");
412-
arguments.OverrideConfig.ShouldBeEquivalentTo(expected);
395+
396+
ConfigurationHelper configruationHelper = new(arguments.OverrideConfig);
397+
configruationHelper.Configuration.ShouldBeEquivalentTo(expected);
413398
}
414399

415400
private static IEnumerable<TestCaseData> OverrideConfigWithSingleOptionTestData()
@@ -464,10 +449,10 @@ private static IEnumerable<TestCaseData> OverrideConfigWithSingleOptionTestData(
464449
}
465450
);
466451
yield return new TestCaseData(
467-
"continuous-delivery-fallback-label=cd-label",
452+
"label=cd-label",
468453
new GitVersionConfiguration
469454
{
470-
ContinuousDeploymentFallbackLabel = "cd-label"
455+
Label = "cd-label"
471456
}
472457
);
473458
yield return new TestCaseData(
@@ -546,7 +531,8 @@ private static IEnumerable<TestCaseData> OverrideConfigWithSingleOptionTestData(
546531
public void OverrideConfigWithMultipleOptions(string options, GitVersionConfiguration expected)
547532
{
548533
var arguments = this.argumentParser.ParseArguments(options);
549-
arguments.OverrideConfig.ShouldBeEquivalentTo(expected);
534+
ConfigurationHelper configruationHelper = new(arguments.OverrideConfig);
535+
configruationHelper.Configuration.ShouldBeEquivalentTo(expected);
550536
}
551537

552538
private static IEnumerable<TestCaseData> OverrideConfigWithMultipleOptionsTestData()

src/GitVersion.App.Tests/GitVersion.App.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<ItemGroup>
4-
<PackageReference Include="Mono.Cecil"/>
4+
<PackageReference Include="Mono.Cecil" />
55
</ItemGroup>
66
<ItemGroup>
77
<ProjectReference Include="..\GitVersion.Core\GitVersion.Core.csproj" />

src/GitVersion.App/ArgumentParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ private static void ParseOverrideConfig(Arguments arguments, IReadOnlyCollection
437437
}
438438
parser.SetValue(optionKey, keyAndValue[1]);
439439
}
440-
arguments.OverrideConfig = parser.GetConfig();
440+
arguments.OverrideConfig = parser.GetOverrideConfiguration();
441441
}
442442

443443
private static void ParseUpdateAssemblyInfo(Arguments arguments, string? value, IReadOnlyCollection<string>? values)

src/GitVersion.App/Arguments.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using GitVersion.Configuration;
21
using GitVersion.Logging;
32

43
namespace GitVersion;
@@ -8,7 +7,7 @@ public class Arguments
87
public AuthenticationInfo Authentication = new();
98

109
public string? ConfigFile;
11-
public GitVersionConfiguration? OverrideConfig;
10+
public IReadOnlyDictionary<object, object?> OverrideConfig;
1211
public bool ShowConfig;
1312

1413
public string? TargetPath;
@@ -62,7 +61,7 @@ public GitVersionOptions ToOptions()
6261
ConfigInfo =
6362
{
6463
ConfigFile = ConfigFile,
65-
OverrideConfig = OverrideConfig,
64+
OverrideConfiguration = OverrideConfig,
6665
ShowConfig = ShowConfig
6766
},
6867

src/GitVersion.App/GitVersionExecutor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ private int RunGitVersionTool(GitVersionOptions gitVersionOptions)
6464

6565
var variables = this.gitVersionCalculateTool.CalculateVersionVariables();
6666

67-
var configuration = this.configurationProvider.Provide(gitVersionOptions.ConfigInfo.OverrideConfig);
67+
var configuration = this.configurationProvider.Provide(gitVersionOptions.ConfigInfo.OverrideConfiguration);
6868

69-
this.gitVersionOutputTool.OutputVariables(variables, configuration.UpdateBuildNumber ?? true);
69+
this.gitVersionOutputTool.OutputVariables(variables, configuration.UpdateBuildNumber);
7070
this.gitVersionOutputTool.UpdateAssemblyInfo(variables);
7171
this.gitVersionOutputTool.UpdateWixVersionFile(variables);
7272
}

0 commit comments

Comments
 (0)