Skip to content

Commit baaab9a

Browse files
authored
Merge pull request #4220 from selfdocumentingcode/docs/some-fixes
Improve documentation around version strategies
2 parents 7bc87f4 + 5f4ca13 commit baaab9a

File tree

3 files changed

+31
-26
lines changed

3 files changed

+31
-26
lines changed

docs/input/docs/learn/how-it-works.md

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,51 +19,54 @@ GitVersion has three distinct steps for calculating versions in v3.
1919
1. If the current commit is tagged, the tag is used and build metadata
2020
(excluding commit count) is added. The other two steps will not execute.
2121
2. A set of strategies are evaluated to decide on the base version and some
22-
metadata about that version. These strategies include HighestReachableTag,
23-
NextVersionInConfig, MergedBranchWithVersion, VersionInBranchName etc.
22+
metadata about that version. See [Version Strategies](#version-strategies)
2423
3. The highest base version is selected, using that base version as the new
2524
version is calculated.
2625

2726
Visually it looks something like this:
2827

29-
![Version Calculation](https://www.plantuml.com/plantuml/png/fLCxJyCm4DxzAsuib4P914i69De1CS38Vd6kYIN7ZcodK8aVp-KX6Y2fKCbY9NV-7lVb2WoOeoVOMRDNfH0lz1vUoNbbpGwrR3K6ws1p3rlk-bN8u972f2AC3GHEbLN8m1D1Jjg-mPuXAZvx9kL1ZW1KY5dOZczMI0Pf54VnHtf7jpaAWJg0sW-uXw4PK3Eb1sMaevfCW6i1\_0m6po1l7HfPJUxvu5XYUOHLWq5MLptCudmMK9--u5glJ0dIEaVo1Dw3JgVM6Km4cM9mzyrQXHuQHnj7chhl0JcnIrHjno1wiWtgfi8eWVK\_7OQAmBHrJWvORFVM2PmrE7AcWZGh-Lj0FvptVvLiUPnCdG_XhNhOov9wQ1fzv7nw5S5EwSvw6CDQNfnMwUAP0XQyQpj70nkx3Nn3p5NFY9IshbNWepKi8ublWFiSPkC0ee8El75Dv5aOxqZQBScbWpWn0Pe2wb6aM1p4Eea\_0G00)
28+
![Version Calculation](https://www.plantuml.com/plantuml/png/fLCxJyCm4DxzAsuib4P914i69De1CS38Vd6kYIN7ZcodK8aVp-KX6Y2fKCbY9NV-7lVb2WoOeoVOMRDNfH0lz1vUoNbbpGwrR3K6ws1p3rlk-bN8u972f2AC3GHEbLN8m1D1Jjg-mPuXAZvx9kL1ZW1KY5dOZczMI0Pf54VnHtf7jpaAWJg0sW-uXw4PK3Eb1sMaevfCW6i1_0m6po1l7HfPJUxvu5XYUOHLWq5MLptCudmMK9--u5glJ0dIEaVo1Dw3JgVM6Km4cM9mzyrQXHuQHnj7chhl0JcnIrHjno1wiWtgfi8eWVK_7OQAmBHrJWvORFVM2PmrE7AcWZGh-Lj0FvptVvLiUPnCdG_XhNhOov9wQ1fzv7nw5S5EwSvw6CDQNfnMwUAP0XQyQpj70nkx3Nn3p5NFY9IshbNWepKi8ublWFiSPkC0ee8El75Dv5aOxqZQBScbWpWn0Pe2wb6aM1p4Eea_0G00)
3029

31-
[Edit Diagram](https://www.plantuml.com/plantuml/form?url=https://www.plantuml.com/plantuml/png/fLCxJyCm4DxzAsuib4P914i69De1CS38Vd6kYIN7ZcodK8aVp-KX6Y2fKCbY9NV-7lVb2WoOeoVOMRDNfH0lz1vUoNbbpGwrR3K6ws1p3rlk-bN8u972f2AC3GHEbLN8m1D1Jjg-mPuXAZvx9kL1ZW1KY5dOZczMI0Pf54VnHtf7jpaAWJg0sW-uXw4PK3Eb1sMaevfCW6i1\_0m6po1l7HfPJUxvu5XYUOHLWq5MLptCudmMK9--u5glJ0dIEaVo1Dw3JgVM6Km4cM9mzyrQXHuQHnj7chhl0JcnIrHjno1wiWtgfi8eWVK\_7OQAmBHrJWvORFVM2PmrE7AcWZGh-Lj0FvptVvLiUPnCdG_XhNhOov9wQ1fzv7nw5S5EwSvw6CDQNfnMwUAP0XQyQpj70nkx3Nn3p5NFY9IshbNWepKi8ublWFiSPkC0ee8El75Dv5aOxqZQBScbWpWn0Pe2wb6aM1p4Eea\_0G00)
30+
[Edit Diagram](https://www.plantuml.com/plantuml/uml/fLCxJyCm4DxzAsuib4P914i69De1CS38Vd6kYIN7ZcodK8aVp-KX6Y2fKCbY9NV-7lVb2WoOeoVOMRDNfH0lz1vUoNbbpGwrR3K6ws1p3rlk-bN8u972f2AC3GHEbLN8m1D1Jjg-mPuXAZvx9kL1ZW1KY5dOZczMI0Pf54VnHtf7jpaAWJg0sW-uXw4PK3Eb1sMaevfCW6i1_0m6po1l7HfPJUxvu5XYUOHLWq5MLptCudmMK9--u5glJ0dIEaVo1Dw3JgVM6Km4cM9mzyrQXHuQHnj7chhl0JcnIrHjno1wiWtgfi8eWVK_7OQAmBHrJWvORFVM2PmrE7AcWZGh-Lj0FvptVvLiUPnCdG_XhNhOov9wQ1fzv7nw5S5EwSvw6CDQNfnMwUAP0XQyQpj70nkx3Nn3p5NFY9IshbNWepKi8ublWFiSPkC0ee8El75Dv5aOxqZQBScbWpWn0Pe2wb6aM1p4Eea_0G00)
3231

3332
**\*** Some strategies allow the version to be incremented, others don't. More
3433
info below.
3534
**+** This version is out of context with the rest of the example. It is here
3635
simply to show what happens if the check is true.
3736

38-
### Base Version Strategies
37+
### Version Strategies
3938

4039
Currently we have the following strategies:
4140

42-
* `HighestTagBaseVersionStrategy` - Finds the highest reachable tag from the
43-
current branch
44-
* `VersionInBranchBaseVersionStrategy` - Extracts version information from the
45-
branch name (e.g., `release/3.0.0` will find `3.0.0`)
46-
* `ConfigNextVersionBaseVersionStrategy` - Returns the version from the
47-
GitVersion.yaml file
48-
* `MergeMessageBaseVersionStrategy` - Finds version numbers from merge messages
49-
(e.g., `Merge 'release/3.0.0' into 'main'` will return `3.0.0`)
50-
* `FallbackBaseVersionStrategy` - Always returns 0.0.0 and will be used for
41+
* `Fallback` - Always returns 0.0.0 and will be used for
5142
calculating the next version which is dependent on the increment strategy of
52-
the effected branch (e.g. on main the next version is 0.0.1 or on develop it is 0.1.0)
43+
the effected branch (e.g. on main the next version is 0.0.1 or on develop it is 0.1.0).
44+
The fallback strategy only applies if no other selected strategy returns a base version.
45+
* `ConfiguredNextVersion` - Returns the version from the GitVersion.yaml file
46+
* `MergeMessage` - Finds version numbers from merge messages
47+
(e.g., `Merge 'release/3.0.0' into 'main'` will return `3.0.0`)
48+
* `TaggedCommit` - Extracts version information from all tags on the branch which are valid,
49+
and not newer than the current commit.
50+
* `TrackReleaseBranches` - Considers the base version extracted from release branches when
51+
calculating the next version for branches configured with `track-release-branches: true`
52+
(part of default configuration for `develop` branch in `GitFlow` workflow)
53+
* `VersionInBranchName` - Extracts version information from the
54+
branch name (e.g., `release/3.0.0` will find `3.0.0`)
55+
* `Mainline` - Increments the version on every commit for branches configured with `is-main-branch: true`
5356

5457
Each strategy needs to return an instance of `BaseVersion` which has the
5558
following properties:
5659

5760
* `Source` - Description of the source (e.g., `Merge message 'Merge 'release/3.0.0' into 'main'`)
5861
* `ShouldIncrement` - Some strategies should have the version incremented,
59-
others do not (e.g., `ConfigNextVersionBaseVersionStrategy` returns false,
60-
`HighestTagBaseVersionStrategy` returns true)
62+
others do not (e.g., `ConfiguredNextVersion` returns false,
63+
`TaggedCommit` returns true)
6164
* `SemanticVersion` - SemVer of the base version strategy
6265
* `BaseVersionSource` - SHA hash of the source. Commits will be counted from
63-
this hash. Can be null (e.g., `ConfigNextVersionBaseVersionStrategy` returns
66+
this hash. Can be null (e.g., `ConfiguredNextVersion` returns
6467
null).
6568
* `BranchNameOverride` - When `useBranchName` or `{BranchName}` is used in the
6669
tag configuration, this allows the branch name to be changed by a base version.
67-
`VersionInBranchBaseVersionStrategy` uses this to strip out anything before the
70+
`VersionInBranchName` uses this to strip out anything before the
6871
first `-` or `/.` so `foo` ends up being evaluated as `foo`. If in doubt, just
6972
use null.

docs/input/docs/reference/mdsource/configuration.source.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -550,15 +550,17 @@ Example of invalid `Strict`, but valid `Loose`
550550

551551
### strategies
552552

553-
Specifies which version strategy implementation (one ore more) will be used to determine the next version. Following values are supported and can be combined:
553+
Specifies which version strategy implementation (one or more) will be used to determine the next version.
554+
These strategies can be combined, and the order in which they are specified does not matter.
555+
The configuration accepts the following values:
554556

555557
- Fallback
556558
- ConfiguredNextVersion
557559
- MergeMessage
558560
- TaggedCommit
559561
- TrackReleaseBranches
560562
- VersionInBranchName
561-
- TrunkBased
563+
- Mainline
562564

563565
[1145]: https://github.com/GitTools/GitVersion/issues/1145
564566
[1366]: https://github.com/GitTools/GitVersion/issues/1366

docs/readme.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ To serve up the documentation locally, you need to run the following
2121
commands:
2222

2323
```shell
24-
./build.ps1 -Stage build -Target PrepareBuild
24+
./build.ps1 -Stage build -Target BuildPrepare
2525
./build.ps1 -Stage build -Target Build
2626
./build.ps1 -Stage docs -Target PreviewDocs
2727
```
@@ -32,7 +32,7 @@ On Windows, you need to run the following commands in a PowerShell
3232
terminal:
3333

3434
```shell
35-
./build.ps1 -Stage build -Target PrepareBuild
35+
./build.ps1 -Stage build -Target BuildPrepare
3636
./build.ps1 -Stage build -Target Build
3737
./build.ps1 -Stage docs -Target PreviewDocs
3838
```
@@ -43,14 +43,14 @@ First you need to [install PowerShell on macOS][ps-mac] or [Linux][ps-linux],
4343
then execute the following commands:
4444

4545
```shell
46-
./build.ps1 -Stage build -Target PrepareBuild
46+
./build.ps1 -Stage build -Target BuildPrepare
4747
./build.ps1 -Stage build -Target Build
4848
./build.ps1 -Stage docs -Target PreviewDocs
4949
```
5050

5151
After pressing enter, the documentation will be generated and then served under
52-
a local web server. Information about the URL that can be used to view the docs
53-
will be shown in the output. Copy/paste this URL into a browser window.
52+
a local web server. Information about the URL that can be used to view the docs
53+
will be shown in the output. Copy/paste this URL into a browser window.
5454

5555
[gitversion.net]: https://gitversion.net/
5656
[forking]: https://guides.github.com/activities/forking/

0 commit comments

Comments
 (0)