Skip to content

Commit 34feeaa

Browse files
authored
Merge pull request #4810 from GitTools/copilot/rename-commits-to-version-distance
VersionSourceDistance as a replacement for the existing CommitsSinceVersionSource
2 parents 9a3821a + 849db8a commit 34feeaa

43 files changed

Lines changed: 182 additions & 190 deletions

File tree

Some content is hidden

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

build/common/Addins/GitVersion/GitVersion.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ public sealed class GitVersion
9595
/// </summary>
9696
public int? CommitsSinceVersionSource { get; set; }
9797

98+
/// <summary>
99+
/// Gets or sets the version source distance.
100+
/// </summary>
101+
public int? VersionSourceDistance { get; set; }
102+
98103
/// <summary>
99104
/// Gets or sets the commit date.
100105
/// </summary>

docs/input/docs/reference/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ When `release-2.0.0` is merged into main, we want main to build `2.0.0`. If
907907
prevents incrementing after a versioned branch is merged.
908908

909909
In a GitFlow-based repository, setting this option can have implications on the
910-
`CommitsSinceVersionSource` output variable. It can rule out a potentially
910+
`VersionSourceDistance` output variable. It can rule out a potentially
911911
better version source proposed by the `MergeMessageBaseVersionStrategy`. For
912912
more details and an in-depth analysis, please see [the discussion][2506].
913913

docs/input/docs/reference/custom-formatting.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ assembly-informational-format: "{Major}.{Minor}.{Patch:F2}-{PreReleaseLabel}"
3030
- `F` or `f` (Fixed-point): `{Patch:F2}` → `"1.23"`
3131
- `N` or `n` (Number): `{BuildMetadata:N0}` → `"1,234"`
3232
- `C` or `c` (Currency): `{Major:C}` → `"¤1.00"`
33-
- `P` or `p` (Percent): `{CommitsSinceVersionSource:P}` → `"12,345.60 %"`
33+
- `P` or `p` (Percent): `{VersionSourceDistance:P}` → `"12,345.60 %"`
3434
- `D` or `d` (Decimal): `{Major:D4}` → `"0001"`
3535
- `B` or `b` (Binary): `{Minor:B4}` → `"0101"`
3636
- `X` or `x` (Hexadecimal): `{Patch:X}` → `"FF"`
@@ -72,14 +72,14 @@ branches:
7272
feature:
7373
label: "{BranchName:c}" # Converts to PascalCase
7474
75-
assembly-informational-format: "{Major}.{Minor}.{Patch}-{PreReleaseLabel:l}.{CommitsSinceVersionSource:0000}"
75+
assembly-informational-format: "{Major}.{Minor}.{Patch}-{PreReleaseLabel:l}.{VersionSourceDistance:0000}"
7676
```
7777

7878
**Template Usage:**
7979

8080
```yaml
8181
# Using format strings in templates
82-
assembly-informational-format: "{Major}.{Minor}.{Patch}-{CommitsSinceVersionSource:0000}"
82+
assembly-informational-format: "{Major}.{Minor}.{Patch}-{VersionSourceDistance:0000}"
8383
assembly-informational-format: "{SemVer}-{BranchName:l}"
8484
```
8585

@@ -91,7 +91,7 @@ Based on actual test cases from the implementation:
9191

9292
```yaml
9393
# Zero-padded commit count
94-
assembly-informational-format: "{Major}.{Minor}.{Patch}-{CommitsSinceVersionSource:0000}"
94+
assembly-informational-format: "{Major}.{Minor}.{Patch}-{VersionSourceDistance:0000}"
9595
# Result: "1.2.3-0042"
9696
```
9797

@@ -122,7 +122,7 @@ assembly-informational-format: "Cost-{Major:C}" # Result: "Cost-¤1.00"
122122
assembly-informational-format: "Progress-{Minor:P}" # Result: "Progress-200.00 %"
123123
124124
# Thousands separator
125-
assembly-informational-format: "Build-{CommitsSinceVersionSource:N0}" # Result: "Build-1,234"
125+
assembly-informational-format: "Build-{VersionSourceDistance:N0}" # Result: "Build-1,234"
126126
```
127127

128128
## Configuration Integration
@@ -133,9 +133,9 @@ The format strings are used in GitVersion configuration files through various fo
133133

134134
```yaml
135135
# GitVersion.yml
136-
assembly-informational-format: "{Major}.{Minor}.{Patch}-{CommitsSinceVersionSource:0000}"
136+
assembly-informational-format: "{Major}.{Minor}.{Patch}-{VersionSourceDistance:0000}"
137137
assembly-versioning-format: "{Major}.{Minor}.{Patch}.{env:BUILD_NUMBER}"
138-
assembly-file-versioning-format: "{MajorMinorPatch}.{CommitsSinceVersionSource}"
138+
assembly-file-versioning-format: "{MajorMinorPatch}.{VersionSourceDistance}"
139139
```
140140

141141
### Environment Variable Integration
@@ -152,15 +152,15 @@ Based on the actual test implementation:
152152

153153
```yaml
154154
# Example from VariableProviderTests.cs
155-
assembly-informational-format: "{Major}.{Minor}.{Patch}-{CommitsSinceVersionSource:0000}"
156-
# Result: "1.2.3-0042" when CommitsSinceVersionSource = 42
155+
assembly-informational-format: "{Major}.{Minor}.{Patch}-{VersionSourceDistance:0000}"
156+
# Result: "1.2.3-0042" when VersionSourceDistance = 42
157157
158158
# Branch-specific formatting
159159
branches:
160160
feature:
161161
label: "{BranchName:c}" # PascalCase conversion
162162
hotfix:
163-
label: "hotfix.{CommitsSinceVersionSource:00}"
163+
label: "hotfix.{VersionSourceDistance:00}"
164164
```
165165

166166
## Invariant Culture Formatting
@@ -174,7 +174,7 @@ The formatting system uses `CultureInfo.InvariantCulture` by default through the
174174

175175
```csharp
176176
// All environments produce the same output:
177-
// {CommitsSinceVersionSource:N0} → "1,234"
177+
// {VersionSourceDistance:N0} → "1,234"
178178
// {CommitDate:MMM dd, yyyy} → "Mar 15, 2024"
179179
// {Major:C} → "¤1.00" (generic currency symbol)
180180
```

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ When `release-2.0.0` is merged into main, we want main to build `2.0.0`. If
508508
prevents incrementing after a versioned branch is merged.
509509

510510
In a GitFlow-based repository, setting this option can have implications on the
511-
`CommitsSinceVersionSource` output variable. It can rule out a potentially
511+
`VersionSourceDistance` output variable. It can rule out a potentially
512512
better version source proposed by the `MergeMessageBaseVersionStrategy`. For
513513
more details and an in-depth analysis, please see [the discussion][2506].
514514

docs/input/docs/reference/variables.md

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -34,40 +34,42 @@ what is available. For the `release/3.0.0` branch of GitVersion it shows:
3434
"ShortSha": "28c8531",
3535
"VersionSourceSha": "28c853159a46b5a87e6cc9c4f6e940c59d6bc68a",
3636
"CommitsSinceVersionSource": 7,
37+
"VersionSourceDistance": 7,
3738
"CommitDate": "2021-12-31",
3839
"UncommittedChanges": 0
3940
}
4041
```
4142

4243
Each property of the above JSON document is described in the below table.
4344

44-
| Property | Description |
45-
| --------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
46-
| `Major` | The major version. Should be incremented on breaking changes. |
47-
| `Minor` | The minor version. Should be incremented on new features. |
48-
| `Patch` | The patch version. Should be incremented on bug fixes. |
49-
| `PreReleaseTag` | The pre-release tag is the pre-release label suffixed by the `PreReleaseNumber`. |
50-
| `PreReleaseTagWithDash` | The pre-release tag prefixed with a dash. |
51-
| `PreReleaseLabel` | The pre-release label. |
52-
| `PreReleaseLabelWithDash` | The pre-release label prefixed with a dash. |
53-
| `PreReleaseNumber` | The pre-release number. |
54-
| `WeightedPreReleaseNumber` | A summation of branch specific `pre-release-weight` and the `PreReleaseNumber`. Can be used to obtain a monotonically increasing version number across the branches. |
55-
| `BuildMetaData` | The build metadata, usually representing number of commits since the `VersionSourceSha`. Despite its name, will not increment for every build. |
56-
| `FullBuildMetaData` | The `BuildMetaData` suffixed with `BranchName` and `Sha`. |
57-
| `MajorMinorPatch` | `Major`, `Minor` and `Patch` joined together, separated by `.`. |
58-
| `SemVer` | The semantical version number, including `PreReleaseTagWithDash` for pre-release version numbers. |
59-
| `AssemblySemVer` | Suitable for .NET `AssemblyVersion`. Defaults to `Major.Minor.0.0` to allow the assembly to be hotfixed without breaking existing applications that may be referencing it. |
60-
| `AssemblySemFileVer` | Suitable for .NET `AssemblyFileVersion`. Defaults to `Major.Minor.Patch.0`. |
61-
| `InformationalVersion` | Suitable for .NET `AssemblyInformationalVersion`. Defaults to `FullSemVer` suffixed by `FullBuildMetaData`. |
62-
| `FullSemVer` | The full, SemVer 2.0 compliant version number. |
63-
| `BranchName` | The name of the checked out Git branch. |
64-
| `EscapedBranchName` | Equal to `BranchName`, but with `/` replaced with `-`. |
65-
| `Sha` | The SHA of the Git commit. |
66-
| `ShortSha` | The `Sha` limited to 7 characters. |
67-
| `VersionSourceSha` | The SHA of the commit used as version source. |
68-
| `CommitsSinceVersionSource` | The number of commits since the version source. |
69-
| `CommitDate` | The ISO-8601 formatted date of the commit identified by `Sha`. |
70-
| `UncommittedChanges` | The number of uncommitted changes present in the repository. |
45+
| Property | Description |
46+
|----------------------------:|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
47+
| `Major` | The major version. Should be incremented on breaking changes. |
48+
| `Minor` | The minor version. Should be incremented on new features. |
49+
| `Patch` | The patch version. Should be incremented on bug fixes. |
50+
| `PreReleaseTag` | The pre-release tag is the pre-release label suffixed by the `PreReleaseNumber`. |
51+
| `PreReleaseTagWithDash` | The pre-release tag prefixed with a dash. |
52+
| `PreReleaseLabel` | The pre-release label. |
53+
| `PreReleaseLabelWithDash` | The pre-release label prefixed with a dash. |
54+
| `PreReleaseNumber` | The pre-release number. |
55+
| `WeightedPreReleaseNumber` | A summation of branch specific `pre-release-weight` and the `PreReleaseNumber`. Can be used to obtain a monotonically increasing version number across the branches. |
56+
| `BuildMetaData` | The build metadata, usually representing number of commits since the `VersionSourceSha`. Despite its name, will not increment for every build. |
57+
| `FullBuildMetaData` | The `BuildMetaData` suffixed with `BranchName` and `Sha`. |
58+
| `MajorMinorPatch` | `Major`, `Minor` and `Patch` joined together, separated by `.`. |
59+
| `SemVer` | The semantical version number, including `PreReleaseTagWithDash` for pre-release version numbers. |
60+
| `AssemblySemVer` | Suitable for .NET `AssemblyVersion`. Defaults to `Major.Minor.0.0` to allow the assembly to be hotfixed without breaking existing applications that may be referencing it. |
61+
| `AssemblySemFileVer` | Suitable for .NET `AssemblyFileVersion`. Defaults to `Major.Minor.Patch.0`. |
62+
| `InformationalVersion` | Suitable for .NET `AssemblyInformationalVersion`. Defaults to `FullSemVer` suffixed by `FullBuildMetaData`. |
63+
| `FullSemVer` | The full, SemVer 2.0 compliant version number. |
64+
| `BranchName` | The name of the checked out Git branch. |
65+
| `EscapedBranchName` | Equal to `BranchName`, but with `/` replaced with `-`. |
66+
| `Sha` | The SHA of the Git commit. |
67+
| `ShortSha` | The `Sha` limited to 7 characters. |
68+
| `VersionSourceSha` | The SHA of the commit used as version source. |
69+
| `CommitsSinceVersionSource` | (Deprecated: use `VersionSourceDistance` instead) The number of commits since the version source. |
70+
| `VersionSourceDistance` | The number of commits since the version source. |
71+
| `CommitDate` | The ISO-8601 formatted date of the commit identified by `Sha`. |
72+
| `UncommittedChanges` | The number of uncommitted changes present in the repository. |
7173

7274
Depending on how and in which context GitVersion is executed (for instance
7375
within a [supported build server][build-servers]), the above version variables

src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<RepositoryType>git</RepositoryType>
2020

2121
<NoWarn>$(NoWarn);NU1701;1591,8618,SYSLIB10;EnableGenerateDocumentationFile</NoWarn>
22-
<NoWarn>$(NoWarn);CS8604;CS8620</NoWarn>
22+
<NoWarn>$(NoWarn);CS8604;CS8620;CS0618</NoWarn>
2323
<WarningsAsErrors>$(WarningsAsErrors);RS0016;RS0017;RS0022;RS0024;RS0025;RS0026;RS0027</WarningsAsErrors>
2424

2525
<DebugType>embedded</DebugType>

0 commit comments

Comments
 (0)