Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 73 additions & 37 deletions build/common/Addins/GitVersion/GitVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,102 +6,138 @@ namespace Common.Addins.GitVersion;
public sealed class GitVersion
{
/// <summary>
/// Gets or sets the major version.
/// Gets or sets the assembly semantic file version. Suitable for .NET AssemblyFileVersion. Defaults to Major.Minor.Patch.0.
/// </summary>
public int Major { get; set; }
public string? AssemblySemFileVer { get; set; }

/// <summary>
/// Gets or sets the minor version.
/// Gets or sets the assembly Semantic Version. Suitable for .NET AssemblyVersion. Defaults to Major.Minor.0.0.
/// </summary>
public int Minor { get; set; }
public string? AssemblySemVer { get; set; }

/// <summary>
/// Gets or sets the patch version.
/// Gets or sets the branch name. The name of the checked out Git branch.
/// </summary>
public int Patch { get; set; }
public string? BranchName { get; set; }

/// <summary>
/// Gets or sets the pre-release tag.
/// Gets or sets the build metadata, usually representing number of commits since the VersionSourceSha.
/// </summary>
public string? PreReleaseTag { get; set; }
public int? BuildMetaData { get; set; }

/// <summary>
/// Gets or sets the pre-release tag with dash.
/// Gets or sets the commit date. The ISO-8601 formatted date of the commit identified by Sha.
/// </summary>
public string? PreReleaseTagWithDash { get; set; }
public string? CommitDate { get; set; }

/// <summary>
/// Gets or sets the pre-release label.
/// Gets or sets the commits since version source.
/// </summary>
public string? PreReleaseLabel { get; set; }
[Obsolete("CommitsSinceVersionSource has been deprecated. Use VersionSourceDistance instead.")]
public int? CommitsSinceVersionSource { get; set; }

/// <summary>
/// Gets or sets the pre-release number.
/// Gets or sets the escaped branch name. Equal to BranchName, but with / replaced with -.
/// </summary>
public int? PreReleaseNumber { get; set; }
public string? EscapedBranchName { get; set; }

/// <summary>
/// Gets or sets the build metadata.
/// Gets or sets the full build metadata. The BuildMetaData suffixed with BranchName and Sha.
/// </summary>
public string? BuildMetaData { get; set; }
public string? FullBuildMetaData { get; set; }

/// <summary>
/// Gets or sets the major version.
/// Gets or sets the full Semantic Version. The full, SemVer 2.0 compliant version number.
/// </summary>
public string? FullBuildMetaData { get; set; }
public string? FullSemVer { get; set; }

/// <summary>
/// Gets or sets the major, minor, and path.
/// Gets or sets the informational version. Suitable for .NET AssemblyInformationalVersion. Defaults to FullSemVer suffixed by FullBuildMetaData.
/// </summary>
public string? InformationalVersion { get; set; }

/// <summary>
/// Gets or sets the major version. Should be incremented on breaking changes.
/// </summary>
public int? Major { get; set; }

/// <summary>
/// Gets or sets the major, minor, and patch. Major, Minor and Patch joined together, separated by '.'.
/// </summary>
public string? MajorMinorPatch { get; set; }

/// <summary>
/// Gets or sets the Semantic Version.
/// Gets or sets the minor version. Should be incremented on new features.
/// </summary>
public string? SemVer { get; set; }
public int? Minor { get; set; }

/// <summary>
/// Gets or sets the assembly Semantic Version.
/// Gets or sets the patch version. Should be incremented on bug fixes.
/// </summary>
public string? AssemblySemVer { get; set; }
public int? Patch { get; set; }

/// <summary>
/// Gets or sets the assembly semantic file version.
/// Gets or sets the pre-release label. The pre-release label is the name of the pre-release.
/// </summary>
public string? AssemblySemFileVer { get; set; }
public string? PreReleaseLabel { get; set; }

/// <summary>
/// Gets or sets the full Semantic Version.
/// Gets or sets the pre-release label with dash. The pre-release label prefixed with a dash.
/// </summary>
public string? FullSemVer { get; set; }
public string? PreReleaseLabelWithDash { get; set; }

/// <summary>
/// Gets or sets the informational version.
/// Gets or sets the pre-release number. The pre-release number is the number of commits since the last version bump.
/// </summary>
public string? InformationalVersion { get; set; }
public int? PreReleaseNumber { get; set; }

/// <summary>
/// Gets or sets the branch name.
/// Gets or sets the pre-release tag. The pre-release tag is the pre-release label suffixed by the PreReleaseNumber.
/// </summary>
public string? BranchName { get; set; }
public string? PreReleaseTag { get; set; }

/// <summary>
/// Gets or sets the pre-release tag with dash. The pre-release tag prefixed with a dash.
/// </summary>
public string? PreReleaseTagWithDash { get; set; }

/// <summary>
/// Gets or sets the Semantic Version. The semantic version number, including PreReleaseTagWithDash for pre-release version numbers.
/// </summary>
public string? SemVer { get; set; }

/// <summary>
/// Gets or sets the Git SHA.
/// Gets or sets the Git SHA. The SHA of the Git commit.
/// </summary>
public string? Sha { get; set; }

/// <summary>
/// Gets or sets the commits since version source.
/// Gets or sets the short SHA. The Sha limited to 7 characters.
/// </summary>
public int? CommitsSinceVersionSource { get; set; }
public string? ShortSha { get; set; }

/// <summary>
/// Gets or sets the number of uncommitted changes present in the repository.
/// </summary>
public int? UncommittedChanges { get; set; }

/// <summary>
/// Gets or sets the version source distance.
/// Gets or sets the version source distance. The number of commits since the version source.
/// </summary>
public int? VersionSourceDistance { get; set; }

/// <summary>
/// Gets or sets the commit date.
/// Gets or sets the version source SemVer. The semantic version of the commit used as version source.
/// </summary>
public string? CommitDate { get; set; }
public string? VersionSourceSemVer { get; set; }

/// <summary>
/// Gets or sets the version source SHA. The SHA of the commit used as version source.
/// </summary>
public string? VersionSourceSha { get; set; }

/// <summary>
/// Gets or sets the weighted pre-release number. A summation of branch specific pre-release-weight and the PreReleaseNumber. Can be used to obtain a monotonically increasing version number across the branches.
/// </summary>
public int? WeightedPreReleaseNumber { get; set; }
}
4 changes: 2 additions & 2 deletions build/common/Addins/GitVersion/GitVersionAliases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace Common.Addins.GitVersion;
/// <summary>
/// <para>Contains functionality related to <see href="https://github.com/gittools/gitversion">GitVersion</see>.</para>
/// <para>
/// In order to use the commands for this alias, include the following in your build.cake file to download and
/// To use the commands for this alias, include the following in your build.cake file to download and
/// install from nuget.org, or specify the ToolPath within the <see cref="GitVersionSettings" /> class:
/// <code>
/// #tool "nuget:?package=GitVersion.CommandLine"
Expand Down Expand Up @@ -58,7 +58,7 @@ public GitVersion GitVersion()
{
ArgumentNullException.ThrowIfNull(context);

return GitVersion(context, new GitVersionSettings());
return context.GitVersion(new GitVersionSettings());
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion build/common/Utilities/Models.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static BuildVersion Calculate(GitVersion gitVersion)
chocolateyVersion += $"-{prefix}{gitVersion.PreReleaseTag?.Replace(".", "-")}";
}

if (!string.IsNullOrWhiteSpace(gitVersion.BuildMetaData))
if (gitVersion.BuildMetaData is not null)
{
semVersion += $"-{gitVersion.BuildMetaData}";
chocolateyVersion += $"-{gitVersion.BuildMetaData}";
Expand Down
64 changes: 32 additions & 32 deletions docs/input/docs/reference/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,67 +11,67 @@ what is available. For the `release/3.0.0` branch of GitVersion it shows:

```json
{
"AssemblySemFileVer": "3.22.11.0",
"AssemblySemVer": "3.22.11.0",
"BranchName": "release/3.022.011",
"BuildMetaData": 88,
"CommitDate": "2021-12-31",
"CommitsSinceVersionSource": 7,
"EscapedBranchName": "release-3.022.011",
"FullBuildMetaData": "99.Branch.release/3.22.11.Sha.28c853159a46b5a87e6cc9c4f6e940c59d6bc68a",
"FullSemVer": "3.22.11-beta.99+88",
"InformationalVersion": "3.22.11-beta.99+88.Branch.release/3.022.011.Sha.28c853159a46b5a87e6cc9c4f6e940c59d6bc68a",
"Major": 3,
"MajorMinorPatch": "3.22.11",
"Minor": 22,
"Patch": 11,
"PreReleaseTag": "beta.99",
"PreReleaseTagWithDash": "-beta.99",
"PreReleaseLabel": "beta",
"PreReleaseLabelWithDash": "-beta",
"PreReleaseNumber": 99,
"WeightedPreReleaseNumber": 1099,
"BuildMetaData": 88,
"FullBuildMetaData": "99.Branch.release/3.22.11.Sha.28c853159a46b5a87e6cc9c4f6e940c59d6bc68a",
"MajorMinorPatch": "3.22.11",
"PreReleaseTag": "beta.99",
"PreReleaseTagWithDash": "-beta.99",
"SemVer": "3.22.11-beta.99",
"AssemblySemVer": "3.22.11.0",
"AssemblySemFileVer": "3.22.11.0",
"InformationalVersion": "3.22.11-beta.99+88.Branch.release/3.022.011.Sha.28c853159a46b5a87e6cc9c4f6e940c59d6bc68a",
"FullSemVer": "3.22.11-beta.99+88",
"BranchName": "release/3.022.011",
"EscapedBranchName": "release-3.022.011",
"Sha": "28c853159a46b5a87e6cc9c4f6e940c59d6bc68a",
"ShortSha": "28c8531",
"UncommittedChanges": 0,
"VersionSourceDistance": 7,
"VersionSourceSemVer": "3.22.11",
"VersionSourceSha": "28c853159a46b5a87e6cc9c4f6e940c59d6bc68a",
"CommitsSinceVersionSource": 7,
"VersionSourceDistance": 7,
"CommitDate": "2021-12-31",
"UncommittedChanges": 0
"WeightedPreReleaseNumber": 1099
}
```

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

| Property | Description |
|----------------------------:|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `AssemblySemFileVer` | Suitable for .NET `AssemblyFileVersion`. Defaults to `Major.Minor.Patch.0`. |
| `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. |
| `BranchName` | The name of the checked out Git branch. |
| `BuildMetaData` | The build metadata, usually representing number of commits since the `VersionSourceSha`. Despite its name, will not increment for every build. |
| `CommitDate` | The ISO-8601 formatted date of the commit identified by `Sha`. |
| `CommitsSinceVersionSource` | (Deprecated: use `VersionSourceDistance` instead) The number of commits since the version source. |
| `EscapedBranchName` | Equal to `BranchName`, but with `/` replaced with `-`. |
| `FullBuildMetaData` | The `BuildMetaData` suffixed with `BranchName` and `Sha`. |
| `FullSemVer` | The full, SemVer 2.0 compliant version number. |
| `InformationalVersion` | Suitable for .NET `AssemblyInformationalVersion`. Defaults to `FullSemVer` suffixed by `FullBuildMetaData`. |
| `Major` | The major version. Should be incremented on breaking changes. |
| `MajorMinorPatch` | `Major`, `Minor` and `Patch` joined together, separated by `.`. |
| `Minor` | The minor version. Should be incremented on new features. |
| `Patch` | The patch version. Should be incremented on bug fixes. |
| `PreReleaseTag` | The pre-release tag is the pre-release label suffixed by the `PreReleaseNumber`. |
| `PreReleaseTagWithDash` | The pre-release tag prefixed with a dash. |
| `PreReleaseLabel` | The pre-release label. |
| `PreReleaseLabelWithDash` | The pre-release label prefixed with a dash. |
| `PreReleaseNumber` | The pre-release number. |
| `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. |
| `BuildMetaData` | The build metadata, usually representing number of commits since the `VersionSourceSha`. Despite its name, will not increment for every build. |
| `FullBuildMetaData` | The `BuildMetaData` suffixed with `BranchName` and `Sha`. |
| `MajorMinorPatch` | `Major`, `Minor` and `Patch` joined together, separated by `.`. |
| `PreReleaseTag` | The pre-release tag is the pre-release label suffixed by the `PreReleaseNumber`. |
| `PreReleaseTagWithDash` | The pre-release tag prefixed with a dash. |
| `SemVer` | The semantical version number, including `PreReleaseTagWithDash` for pre-release version numbers. |
| `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. |
| `AssemblySemFileVer` | Suitable for .NET `AssemblyFileVersion`. Defaults to `Major.Minor.Patch.0`. |
| `InformationalVersion` | Suitable for .NET `AssemblyInformationalVersion`. Defaults to `FullSemVer` suffixed by `FullBuildMetaData`. |
| `FullSemVer` | The full, SemVer 2.0 compliant version number. |
| `BranchName` | The name of the checked out Git branch. |
| `EscapedBranchName` | Equal to `BranchName`, but with `/` replaced with `-`. |
| `Sha` | The SHA of the Git commit. |
| `ShortSha` | The `Sha` limited to 7 characters. |
| `UncommittedChanges` | The number of uncommitted changes present in the repository. |
| `VersionSourceDistance` | The number of commits since the version source. |
| `VersionSourceSemVer` | The semantic version of the commit used as version source. |
| `VersionSourceSha` | The SHA of the commit used as version source. |
| `CommitsSinceVersionSource` | (Deprecated: use `VersionSourceDistance` instead) The number of commits since the version source. |
| `VersionSourceDistance` | The number of commits since the version source. |
| `CommitDate` | The ISO-8601 formatted date of the commit identified by `Sha`. |
| `UncommittedChanges` | The number of uncommitted changes present in the repository. |
| `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. |

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