Skip to content

Commit 15da5ed

Browse files
authored
Merge pull request #2914 from chris-codeflow/feature/Align-configuration-reference-doc-with-code
Align the Configuration reference documentation with the code
2 parents c180e1e + 3af6dbf commit 15da5ed

File tree

1 file changed

+88
-65
lines changed

1 file changed

+88
-65
lines changed

docs/input/docs/reference/configuration.md

Lines changed: 88 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ Description: Details about how GitVersion can be configured to suit your needs
55
RedirectFrom: docs/configuration
66
---
77

8-
GitVersion from version 3 is mainly powered by configuration and no longer has
9-
branching strategies hard coded.
8+
GitVersion, starting from version 3.0, is mainly powered by configuration and no
9+
longer has branching strategies hard-coded.
1010

1111
## Configuration tool
1212

13-
If you run `gitversion init` you will be launched into a configuration tool, it
14-
can help you configure GitVersion the way you want it.
13+
If you run `gitversion init`, GitVersion will launch into a configuration tool,
14+
which can help you configure GitVersion the way you want it.
1515

1616
Once complete, the `init` command will create a `GitVersion.yml` file in the
1717
working directory. It can be the root repository directory or any subdirectory
@@ -28,21 +28,21 @@ GitHubFlow and GitFlow, probably with others too.
2828
The `develop` branch is set to `ContinuousDeployment` mode by default as we have
2929
found that is generally what is needed when using GitFlow.
3030

31-
You can run `GitVersion /showConfig` to see the effective configuration
32-
(defaults + overrides).
31+
To see the effective configuration (defaults and overrides), you can run
32+
`gitversion /showConfig`.
3333

34-
To create your config file just type `GitVersion init` in your repo directory
35-
after installing via chocolatey and a minimal `GitVersion.yml` configuration
36-
file will be created. Modify this as you need.
34+
To create your config file just type `gitversion init` in your repo directory,
35+
after [installing]. A minimal `GitVersion.yml` configuration file will be
36+
created. Modify this to suit your needs.
3737

3838
## Global configuration
3939

40-
The global configuration look like this:
40+
The global configuration looks like this:
4141

4242
```yaml
4343
next-version: 1.0
4444
assembly-versioning-scheme: MajorMinorPatch
45-
assembly-file-versioning-scheme: MajorMinorPatchTag
45+
assembly-file-versioning-scheme: MajorMinorPatch
4646
assembly-informational-format: '{InformationalVersion}'
4747
mode: ContinuousDelivery
4848
increment: Inherit
@@ -55,20 +55,21 @@ no-bump-message: '\+semver:\s?(none|skip)'
5555
legacy-semver-padding: 4
5656
build-metadata-padding: 4
5757
commits-since-version-source-padding: 4
58+
tag-pre-release-weight: 60000
5859
commit-message-incrementing: Enabled
59-
commit-date-format: 'yyyy-MM-dd'
6060
ignore:
6161
sha: []
6262
commits-before: yyyy-MM-ddTHH:mm:ss
6363
merge-message-formats: {}
64+
update-build-number: true
6465
```
6566
66-
And the description of the available options are:
67+
The details of the available options are as follows:
6768
6869
### next-version
6970
7071
Allows you to bump the next version explicitly, useful for bumping `main` or a
71-
feature with breaking changes a major increment.
72+
feature with breaking changes (i.e., a major increment).
7273

7374
### assembly-versioning-scheme
7475

@@ -142,7 +143,8 @@ branches which do not have one specified. Default set to `ci`.
142143

143144
Just to clarify: For a build name without `...-ci-<buildnumber>` or in other
144145
words without a `PreReleaseTag` (ergo `"PreReleaseTag":""` in GitVersion's JSON output)
145-
at the end you would need to set `continuous-delivery-fallback-tag` to an empty string (`''`):
146+
at the end you would need to set `continuous-delivery-fallback-tag` to an empty
147+
string (`''`):
146148

147149
```yaml
148150
mode: ContinuousDeployment
@@ -154,9 +156,9 @@ Doing so can be helpful if you use your `main` branch as a `release` branch.
154156

155157
### tag-prefix
156158

157-
A regex which is used to trim git tags before processing (eg v1.0.0). Default is
158-
`[vV]` though this is just for illustrative purposes as we do a IgnoreCase match
159-
and could be `v`.
159+
A regex which is used to trim Git tags before processing (e.g., v1.0.0). Default
160+
is `[vV]`, although this is just for illustrative purposes as we do a IgnoreCase
161+
match and could be `v`.
160162

161163
### major-version-bump-message
162164

@@ -185,29 +187,29 @@ none` and `+semver: skip`
185187
### legacy-semver-padding
186188

187189
The number of characters to pad `LegacySemVer` to in the `LegacySemVerPadded`
188-
[variable][variables]. Is default set to `4`, which will pad the
189-
`LegacySemVer` value of `3.0.0-beta1` to `3.0.0-beta0001`.
190+
[variable][variables]. Default is `4`, which will pad the `LegacySemVer` value
191+
of `3.0.0-beta1` to `3.0.0-beta0001`.
190192

191193
### build-metadata-padding
192194

193195
The number of characters to pad `BuildMetaData` to in the `BuildMetaDataPadded`
194-
[variable][variables]. Is default set to `4`, which will pad the
195-
`BuildMetaData` value of `1` to `0001`.
196+
[variable][variables]. Default is `4`, which will pad the `BuildMetaData` value
197+
of `1` to `0001`.
196198

197199
### commits-since-version-source-padding
198200

199201
The number of characters to pad `CommitsSinceVersionSource` to in the
200-
`CommitsSinceVersionSourcePadded` [variable][variables]. Is default set to `4`,
201-
which will pad the `CommitsSinceVersionSource` value of `1` to `0001`.
202+
`CommitsSinceVersionSourcePadded` [variable][variables]. Default is `4`, which
203+
will pad the `CommitsSinceVersionSource` value of `1` to `0001`.
202204

203205
### tag-pre-release-weight
204206

205207
The pre-release weight in case of tagged commits. If the value is not set in the
206208
configuration, a default weight of 60000 is used instead. If the
207-
`WeightedPreReleaseNumber` [variable][variables] is 0 and this
208-
parameter is set, its value is used. This helps if your branching model is
209-
GitFlow and the last release build, which is often tagged, can utilise this
210-
parameter to produce a monotonically increasing build number.
209+
`WeightedPreReleaseNumber` [variable][variables] is 0 and this parameter is set,
210+
its value is used. This helps if your branching model is GitFlow and the last
211+
release build, which is often tagged, can utilise this parameter to produce a
212+
monotonically increasing build number.
211213

212214
### commit-message-incrementing
213215

@@ -255,10 +257,6 @@ Date and time in the format `yyyy-MM-ddTHH:mm:ss` (eg `commits-before:
255257
2015-10-23T12:23:15`) to setup an exclusion range. Effectively any commit before
256258
`commits-before` will be ignored.
257259

258-
### update-build-number
259-
260-
Configures GitVersion to update the build number or not when running on a build server.
261-
262260
### merge-message-formats
263261

264262
Custom merge message formats to enable identification of merge messages that do not
@@ -273,12 +271,16 @@ merge-message-formats:
273271

274272
The regular expression should contain the following capture groups:
275273

276-
* SourceBranch - Identifies the source branch of the merge
277-
* TargetBranch - Identifies the target of the merge
278-
* PullRequestNumber - Captures the pull-request number
274+
* `SourceBranch` - Identifies the source branch of the merge
275+
* `TargetBranch` - Identifies the target branch of the merge
276+
* `PullRequestNumber` - Captures the pull-request number
279277

280278
Custom merge message formats are evaluated _before_ any built in formats.
281279

280+
### update-build-number
281+
282+
Configures GitVersion to update the build number or not when running on a build server.
283+
282284
## Branch configuration
283285

284286
Then we have branch specific configuration, which looks something like this:
@@ -301,27 +303,47 @@ branches:
301303
increment: Patch
302304
prevent-increment-of-merged-branch-version: true
303305
track-merge-target: false
306+
source-branches: [ 'develop', 'release' ]
304307
tracks-release-branches: false
305308
is-release-branch: false
309+
is-mainline: true
310+
pre-release-weight: 55000
311+
develop:
312+
regex: ^dev(elop)?(ment)?$
313+
mode: ContinuousDeployment
314+
tag: alpha
315+
increment: Minor
316+
prevent-increment-of-merged-branch-version: false
317+
track-merge-target: true
318+
source-branches: []
319+
tracks-release-branches: true
320+
is-release-branch: false
321+
is-mainline: false
322+
pre-release-weight: 0
306323
release:
307324
regex: ^releases?[/-]
308325
mode: ContinuousDelivery
309326
tag: beta
310-
increment: Patch
327+
increment: None
311328
prevent-increment-of-merged-branch-version: true
312329
track-merge-target: false
330+
source-branches: [ 'develop', 'main', 'support', 'release' ]
313331
tracks-release-branches: false
314332
is-release-branch: true
315-
pre-release-weight: 1000
333+
is-mainline: false
334+
pre-release-weight: 30000
316335
feature:
317336
regex: ^features?[/-]
318337
mode: ContinuousDelivery
319338
tag: useBranchName
320339
increment: Inherit
321340
prevent-increment-of-merged-branch-version: false
322341
track-merge-target: false
342+
source-branches: [ 'develop', 'main', 'release', 'feature', 'support', 'hotfix' ]
323343
tracks-release-branches: false
324344
is-release-branch: false
345+
is-mainline: false
346+
pre-release-weight: 30000
325347
pull-request:
326348
regex: ^(pull|pull\-requests|pr)[/-]
327349
mode: ContinuousDelivery
@@ -330,39 +352,39 @@ branches:
330352
prevent-increment-of-merged-branch-version: false
331353
tag-number-pattern: '[/-](?<number>\d+)[-/]'
332354
track-merge-target: false
355+
source-branches: [ 'develop', 'main', 'release', 'feature', 'support', 'hotfix' ]
333356
tracks-release-branches: false
334357
is-release-branch: false
358+
is-mainline: false
359+
pre-release-weight: 30000
335360
hotfix:
336361
regex: ^hotfix(es)?[/-]
337362
mode: ContinuousDelivery
338363
tag: beta
339364
increment: Patch
340365
prevent-increment-of-merged-branch-version: false
341366
track-merge-target: false
367+
source-branches: [ 'develop', 'main', 'support' ]
342368
tracks-release-branches: false
343369
is-release-branch: false
370+
is-mainline: false
371+
pre-release-weight: 30000
344372
support:
345373
regex: ^support[/-]
346374
mode: ContinuousDelivery
347375
tag: ''
348376
increment: Patch
349377
prevent-increment-of-merged-branch-version: true
350378
track-merge-target: false
379+
source-branches: [ 'main' ]
351380
tracks-release-branches: false
352381
is-release-branch: false
353-
develop:
354-
regex: ^dev(elop)?(ment)?$
355-
mode: ContinuousDeployment
356-
tag: unstable
357-
increment: Minor
358-
prevent-increment-of-merged-branch-version: false
359-
track-merge-target: true
360-
tracks-release-branches: true
361-
is-release-branch: false
382+
is-mainline: true
383+
pre-release-weight: 55000
362384
```
363385

364-
If you don't specify the regex the inbuilt for that branch config will be used
365-
(recommended)
386+
If you don't specify the regex, the built-in for that branch config will be
387+
used (recommended).
366388

367389
We don't envision many people needing to change most of these configuration
368390
values, but here they are if you need to:
@@ -374,13 +396,13 @@ branch configuration.
374396

375397
### source-branches
376398

377-
Because git commits only refer to parent commits (not branches) GitVersion
399+
Because Git commits only refer to parent commits (not branches) GitVersion
378400
sometimes cannot tell which branch the current branch was branched from.
379401

380402
Take this commit graph
381403

382404
```shell
383-
* release/1.0.0 * feature/foo
405+
* release/v1.0.0 * feature/foo
384406
| ________________/
385407
|/
386408
*
@@ -390,19 +412,19 @@ Take this commit graph
390412

391413
By looking at this graph, you cannot tell which of these scenarios happened:
392414

393-
* feature/foo branches off release/1.0.0
394-
* Branch release/1.0.0 from main
395-
* Branch feature/foo from release/1.0.0
396-
* Add a commit to both release/1.0.0 and feature/foo
397-
* release/1.0.0 is the base for feature/foo
398-
* release/1.0.0 branches off feature/foo
399-
* Branch feature/foo from main
400-
* Branch release/1.0.0 from feature/foo
401-
* Add a commit to both release/1.0.0 and feature/foo
402-
* feature/foo is the base for release/1.0.0
415+
* feature/foo branches off release/v1.0.0
416+
* Branch release/v1.0.0 from main
417+
* Branch feature/foo from release/v1.0.0
418+
* Add a commit to both release/v1.0.0 and feature/foo
419+
* release/v1.0.0 is the base for feature/foo
420+
* release/v1.0.0 branches off feature/foo
421+
* Branch feature/foo from main
422+
* Branch release/v1.0.0 from feature/foo
423+
* Add a commit to both release/v1.0.0 and feature/foo
424+
* feature/foo is the base for release/v1.0.0
403425

404426
Or put more simply, you cannot tell which branch was created first,
405-
`release/1.0.0` or `feature/foo`.
427+
`release/v1.0.0` or `feature/foo`.
406428

407429
To resolve this issue, we give GitVersion a hint about our branching workflows
408430
by telling it what types of branches a branch can be created from. For example,
@@ -509,7 +531,7 @@ branches:
509531

510532
Strategy which will look for tagged merge commits directly off the current
511533
branch. For example `develop` → `release/1.0.0` → merge into `main` and tag
512-
`1.0.0`. The tag is _not_ on develop, but develop should be version `1.0.0` now.
534+
`1.0.0`. The tag is *not* on develop, but develop should be version `1.0.0` now.
513535

514536
### tracks-release-branches
515537

@@ -522,7 +544,7 @@ Indicates this branch config represents a release branch in GitFlow.
522544
### is-mainline
523545

524546
When using Mainline mode, this indicates that this branch is a mainline. By
525-
default support/ and main are mainlines.
547+
default `main` and `support/*` are mainlines.
526548

527549
### pre-release-weight
528550

@@ -535,12 +557,13 @@ same file version: "1.2.3.4". One of the ways to use this value is to set
535557
{Major}.{Minor}.{Patch}.{WeightedPreReleaseNumber}`. If the `pre-release-weight`
536558
is set, it would be added to the `PreReleaseNumber` to get a final
537559
`AssemblySemFileVer`, otherwise a branch specific default for
538-
`pre-release-weight` will be used in the calculation. Related Issues [1145],
539-
[1366]
560+
`pre-release-weight` will be used in the calculation. Related Issues [1145]
561+
and [1366].
540562

541563
[1145]: https://github.com/GitTools/GitVersion/issues/1145
542564
[1366]: https://github.com/GitTools/GitVersion/issues/1366
543565
[2506]: https://github.com/GitTools/GitVersion/pull/2506#issuecomment-754754037
566+
[installing]: /docs/usage/cli/installation
544567
[modes]: /docs/reference/modes
545568
[variables]: /docs/reference/variables
546569
[version-sources]: /docs/reference/version-sources

0 commit comments

Comments
 (0)