diff --git a/docs/input/docs/reference/configuration.md b/docs/input/docs/reference/configuration.md index 9c4dd1a8f6..5cc0409c06 100644 --- a/docs/input/docs/reference/configuration.md +++ b/docs/input/docs/reference/configuration.md @@ -519,6 +519,12 @@ Specifies the format of `AssemblyInformationalVersion`. Follows the same formatting semantics as `assembly-file-versioning-format`. The default value is `{InformationalVersion}`. +### custom-version-format + +Specifies the format of `CustomVersion`. +Follows the same formatting semantics as `assembly-file-versioning-format`. +The default value is `{SemVer}`. + ### mode Sets the `mode` of how GitVersion should create a new version. Read more at diff --git a/docs/input/docs/reference/mdsource/configuration.source.md b/docs/input/docs/reference/mdsource/configuration.source.md index f08c69c816..68ead63675 100644 --- a/docs/input/docs/reference/mdsource/configuration.source.md +++ b/docs/input/docs/reference/mdsource/configuration.source.md @@ -120,6 +120,12 @@ Specifies the format of `AssemblyInformationalVersion`. Follows the same formatting semantics as `assembly-file-versioning-format`. The default value is `{InformationalVersion}`. +### custom-version-format + +Specifies the format of `CustomVersion`. +Follows the same formatting semantics as `assembly-file-versioning-format`. +The default value is `{SemVer}`. + ### mode Sets the `mode` of how GitVersion should create a new version. Read more at diff --git a/docs/input/docs/reference/variables.md b/docs/input/docs/reference/variables.md index 158891797a..c6196f4c89 100644 --- a/docs/input/docs/reference/variables.md +++ b/docs/input/docs/reference/variables.md @@ -27,6 +27,7 @@ what is available. For the `release/3.0.0` branch of GitVersion it shows: "AssemblySemVer": "3.22.11.0", "AssemblySemFileVer": "3.22.11.0", "InformationalVersion": "3.22.11-beta.99+88.Branch.release/3.022.011.Sha.28c853159a46b5a87e6cc9c4f6e940c59d6bc68a", + "CustomVersion": "3.22.11-beta.99", "FullSemVer": "3.22.11-beta.99+88", "BranchName": "release/3.022.011", "EscapedBranchName": "release-3.022.011", @@ -59,6 +60,7 @@ Each property of the above JSON document is described in the below table. | `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`. | +| `CustomVersion` | The custom version, suitable for non-semantic package managers with formatting changes, e.g. NuGet. Defaults to `SemVer`. | | `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 `-`. | diff --git a/docs/input/docs/usage/cli/arguments.md b/docs/input/docs/usage/cli/arguments.md index a406ca76a0..7e89d89298 100644 --- a/docs/input/docs/usage/cli/arguments.md +++ b/docs/input/docs/usage/cli/arguments.md @@ -113,13 +113,13 @@ Double quote character inside of the double quoted `value` has to be be escaped Following options are supported: -1. `assembly-file-versioning-format` -2. `assembly-file-versioning-scheme` -3. `assembly-informational-format` -4. `assembly-versioning-format` -5. `assembly-versioning-scheme` -6. `commit-date-format` -7. `commit-message-incrementing` +1. `assembly-file-versioning-scheme` +2. `assembly-informational-format` +3. `assembly-versioning-format` +4. `assembly-versioning-scheme` +5. `commit-date-format` +6. `commit-message-incrementing` +7. `custom-version-format` 8. `label` 9. `increment` 10. `major-version-bump-message` diff --git a/schemas/6.4/GitVersion.configuration.json b/schemas/6.4/GitVersion.configuration.json new file mode 100644 index 0000000000..76218cc59c --- /dev/null +++ b/schemas/6.4/GitVersion.configuration.json @@ -0,0 +1,434 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://gitversion.net/schemas/6.4/GitVersion.configuration.json", + "title": "GitVersion Configuration (6.4)", + "description": "GitVersion configuration schema (6.4)", + "type": "object", + "properties": { + "assembly-file-versioning-format": { + "description": "Specifies the format of AssemblyFileVersion and overwrites the value of assembly-file-versioning-scheme.", + "type": [ + "string", + "null" + ] + }, + "assembly-file-versioning-scheme": { + "description": "The scheme to use when setting AssemblyFileVersion attribute. Can be 'MajorMinorPatchTag', 'MajorMinorPatch', 'MajorMinor', 'Major', 'None'. Defaults to 'MajorMinorPatch'.", + "default": "MajorMinorPatch", + "enum": [ + "MajorMinorPatchTag", + "MajorMinorPatch", + "MajorMinor", + "Major", + "None", + null + ] + }, + "assembly-informational-format": { + "description": "Specifies the format of AssemblyInformationalVersion. Defaults to '{InformationalVersion}'.", + "default": "'{InformationalVersion}'", + "type": [ + "string", + "null" + ] + }, + "assembly-versioning-format": { + "description": "Specifies the format of AssemblyVersion and overwrites the value of assembly-versioning-scheme.", + "type": [ + "string", + "null" + ] + }, + "assembly-versioning-scheme": { + "description": "The scheme to use when setting AssemblyVersion attribute. Can be 'MajorMinorPatchTag', 'MajorMinorPatch', 'MajorMinor', 'Major', 'None'. Defaults to 'MajorMinorPatch'.", + "default": "MajorMinorPatch", + "enum": [ + "MajorMinorPatchTag", + "MajorMinorPatch", + "MajorMinor", + "Major", + "None", + null + ] + }, + "branches": { + "description": "The header for all the individual branch configuration.", + "type": "object", + "additionalProperties": { + "type": "object", + "properties": { + "commit-message-incrementing": { + "description": "Sets whether it should be possible to increment the version with special syntax in the commit message. Can be 'Disabled', 'Enabled' or 'MergeMessageOnly'.", + "enum": [ + "Enabled", + "Disabled", + "MergeMessageOnly", + null + ] + }, + "mode": { + "description": "The deployment mode for this branch. Can be 'ManualDeployment', 'ContinuousDelivery', 'ContinuousDeployment'.", + "enum": [ + "ManualDeployment", + "ContinuousDelivery", + "ContinuousDeployment", + null + ] + }, + "increment": { + "description": "The increment strategy for this branch. Can be 'Inherit', 'Patch', 'Minor', 'Major', 'None'.", + "$ref": "#/$defs/incrementStrategy" + }, + "is-main-branch": { + "description": "When using Mainline mode, this indicates that this branch is a mainline. By default main and support/* are mainlines.", + "type": [ + "boolean", + "null" + ] + }, + "is-release-branch": { + "description": "Indicates this branch configuration represents a release branch in GitFlow.", + "type": [ + "boolean", + "null" + ] + }, + "is-source-branch-for": { + "description": "The branches that this branch is a source branch.", + "$ref": "#/$defs/hashSetOfString" + }, + "label": { + "description": "The label to use for this branch. Use the value {BranchName} or similar as a placeholder to insert a named capture group from RegularExpression (fx. the branch name).", + "type": [ + "string", + "null" + ] + }, + "pre-release-weight": { + "description": "Provides a way to translate the PreReleaseLabel to a number.", + "type": [ + "integer", + "null" + ] + }, + "prevent-increment": { + "description": "The prevent increment configuration section.", + "$ref": "#/$defs/preventIncrementConfiguration" + }, + "regex": { + "format": "regex", + "description": "The regular expression pattern to use to match this branch.", + "type": [ + "string", + "null" + ] + }, + "source-branches": { + "description": "The source branches for this branch.", + "$ref": "#/$defs/hashSetOfString" + }, + "track-merge-message": { + "description": "This property is a branch related property and gives the user the possibility to control the behavior of whether the merge commit message will be interpreted as a next version or not.", + "type": [ + "boolean", + "null" + ] + }, + "track-merge-target": { + "description": "Strategy which will look for tagged merge commits directly off the current branch.", + "type": [ + "boolean", + "null" + ] + }, + "tracks-release-branches": { + "description": "Indicates this branch configuration represents develop in GitFlow.", + "type": [ + "boolean", + "null" + ] + } + } + } + }, + "commit-date-format": { + "description": "The format to use when calculating the commit date. Defaults to 'yyyy-MM-dd'. See [Standard Date and Time Format Strings](https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings) and [Custom Date and Time Format Strings](https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings).", + "default": "yyyy-MM-dd", + "type": [ + "string", + "null" + ] + }, + "commit-message-incrementing": { + "description": "Sets whether it should be possible to increment the version with special syntax in the commit message. Can be 'Disabled', 'Enabled' or 'MergeMessageOnly'.", + "enum": [ + "Enabled", + "Disabled", + "MergeMessageOnly", + null + ] + }, + "custom-version-format": { + "description": "Specifies the format of CustomVersion. Defaults to '{SemVer}'.", + "default": "'{SemVer}'", + "type": [ + "string", + "null" + ] + }, + "mode": { + "description": "The deployment mode for this branch. Can be 'ManualDeployment', 'ContinuousDelivery', 'ContinuousDeployment'.", + "enum": [ + "ManualDeployment", + "ContinuousDelivery", + "ContinuousDeployment", + null + ] + }, + "ignore": { + "description": "The header property for the ignore configuration.", + "type": "object", + "properties": { + "commits-before": { + "format": "date-time", + "description": "Commits before this date will be ignored. Format: yyyy-MM-ddTHH:mm:ss.", + "type": [ + "string", + "null" + ] + }, + "sha": { + "description": "A sequence of SHAs to be excluded from the version calculations.", + "$ref": "#/$defs/hashSetOfString" + } + } + }, + "increment": { + "description": "The increment strategy for this branch. Can be 'Inherit', 'Patch', 'Minor', 'Major', 'None'.", + "$ref": "#/$defs/incrementStrategy" + }, + "is-main-branch": { + "description": "When using Mainline mode, this indicates that this branch is a mainline. By default main and support/* are mainlines.", + "type": [ + "boolean", + "null" + ] + }, + "is-release-branch": { + "description": "Indicates this branch configuration represents a release branch in GitFlow.", + "type": [ + "boolean", + "null" + ] + }, + "is-source-branch-for": { + "description": "The branches that this branch is a source branch.", + "$ref": "#/$defs/hashSetOfString" + }, + "label": { + "description": "The label to use for this branch. Use the value {BranchName} or similar as a placeholder to insert a named capture group from RegularExpression (fx. the branch name).", + "type": [ + "string", + "null" + ] + }, + "major-version-bump-message": { + "format": "regex", + "description": "The regular expression to match commit messages with to perform a major version increment. Defaults to '\\+semver:\\s?(breaking|major)'", + "default": "\\+semver:\\s?(breaking|major)", + "type": [ + "string", + "null" + ] + }, + "merge-message-formats": { + "description": "Custom merge message formats to enable identification of merge messages that do not follow the built-in conventions.", + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "minor-version-bump-message": { + "format": "regex", + "description": "The regular expression to match commit messages with to perform a minor version increment. Defaults to '\\+semver:\\s?(feature|minor)'", + "default": "\\+semver:\\s?(feature|minor)", + "type": [ + "string", + "null" + ] + }, + "next-version": { + "description": "Allows you to bump the next version explicitly. Useful for bumping main or a feature branch with breaking changes", + "type": [ + "string", + "null" + ] + }, + "no-bump-message": { + "format": "regex", + "description": "Used to tell GitVersion not to increment when in Mainline development mode. Defaults to '\\+semver:\\s?(none|skip)'", + "default": "\\+semver:\\s?(none|skip)", + "type": [ + "string", + "null" + ] + }, + "patch-version-bump-message": { + "format": "regex", + "description": "The regular expression to match commit messages with to perform a patch version increment. Defaults to '\\+semver:\\s?(fix|patch)'", + "default": "\\+semver:\\s?(fix|patch)", + "type": [ + "string", + "null" + ] + }, + "pre-release-weight": { + "description": "Provides a way to translate the PreReleaseLabel to a number.", + "type": [ + "integer", + "null" + ] + }, + "prevent-increment": { + "description": "The prevent increment configuration section.", + "$ref": "#/$defs/preventIncrementConfiguration" + }, + "regex": { + "format": "regex", + "description": "The regular expression pattern to use to match this branch.", + "type": [ + "string", + "null" + ] + }, + "semantic-version-format": { + "description": "Specifies the semantic version format that is used when parsing the string. Can be 'Strict' or 'Loose'. Defaults to 'Strict'.", + "default": "Strict", + "enum": [ + "Strict", + "Loose" + ] + }, + "source-branches": { + "description": "The source branches for this branch.", + "$ref": "#/$defs/hashSetOfString" + }, + "tag-prefix": { + "format": "regex", + "description": "A regular expression which is used to trim Git tags before processing. Defaults to '[vV]?'", + "default": "[vV]?", + "type": [ + "string", + "null" + ] + }, + "tag-pre-release-weight": { + "description": "The pre-release weight in case of tagged commits. Defaults to 60000.", + "type": [ + "integer", + "null" + ] + }, + "track-merge-message": { + "description": "This property is a branch related property and gives the user the possibility to control the behavior of whether the merge commit message will be interpreted as a next version or not.", + "type": [ + "boolean", + "null" + ] + }, + "track-merge-target": { + "description": "Strategy which will look for tagged merge commits directly off the current branch.", + "type": [ + "boolean", + "null" + ] + }, + "tracks-release-branches": { + "description": "Indicates this branch configuration represents develop in GitFlow.", + "type": [ + "boolean", + "null" + ] + }, + "update-build-number": { + "description": "Whether to update the build number in the project file. Defaults to true.", + "default": "true", + "type": "boolean" + }, + "version-in-branch-pattern": { + "format": "regex", + "description": "A regular expression which is used to determine the version number in the branch name or commit message (e.g., v1.0.0-LTS). Defaults to '(?[vV]?\\d+(\\.\\d+)?(\\.\\d+)?).*'.", + "default": "(?[vV]?\\d+(\\.\\d+)?(\\.\\d+)?).*", + "type": [ + "string", + "null" + ] + }, + "strategies": { + "description": "Specifies which version strategies (one or more) will be used to determine the next version. Following values are available: 'ConfiguredNextVersion', 'MergeMessage', 'TaggedCommit', 'TrackReleaseBranches', 'VersionInBranchName' and 'Mainline'.", + "type": "array", + "items": { + "enum": [ + "None", + "Fallback", + "ConfiguredNextVersion", + "MergeMessage", + "TaggedCommit", + "TrackReleaseBranches", + "VersionInBranchName", + "Mainline" + ] + } + }, + "workflow": { + "description": "The base template of the configuration to use. Possible values are: 'GitFlow/v1' or 'GitHubFlow/v1'", + "type": [ + "string", + "null" + ] + } + }, + "$defs": { + "incrementStrategy": { + "enum": [ + "None", + "Major", + "Minor", + "Patch", + "Inherit" + ] + }, + "hashSetOfString": { + "type": "array", + "items": { + "type": "string" + } + }, + "preventIncrementConfiguration": { + "type": "object", + "properties": { + "of-merged-branch": { + "description": "Prevent increment when branch merged.", + "type": [ + "boolean", + "null" + ] + }, + "when-branch-merged": { + "description": "Prevent increment when branch merged.", + "type": [ + "boolean", + "null" + ] + }, + "when-current-commit-tagged": { + "description": "This branch related property controls the behavior whether to use the tagged (value set to true) or the incremented (value set to false) semantic version. Defaults to true.", + "type": [ + "boolean", + "null" + ] + } + } + } + } +} \ No newline at end of file diff --git a/schemas/6.4/GitVersion.json b/schemas/6.4/GitVersion.json new file mode 100644 index 0000000000..fdab933eeb --- /dev/null +++ b/schemas/6.4/GitVersion.json @@ -0,0 +1,191 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://gitversion.net/schemas/6.4/GitVersion.json", + "title": "GitVersion version variables output", + "description": "GitVersion output schema", + "type": "object", + "properties": { + "AssemblySemFileVer": { + "description": "Suitable for .NET AssemblyFileVersion. Defaults to Major.Minor.Patch.0.", + "type": [ + "string", + "null" + ] + }, + "AssemblySemVer": { + "description": "Suitable for .NET AssemblyVersion. Defaults to Major.Minor.0.0", + "type": [ + "string", + "null" + ] + }, + "BranchName": { + "description": "The name of the checked out Git branch.", + "type": [ + "string", + "null" + ] + }, + "BuildMetaData": { + "description": "The build metadata, usually representing number of commits since the VersionSourceSha.", + "type": [ + "integer", + "null" + ] + }, + "CommitDate": { + "description": "The ISO-8601 formatted date of the commit identified by Sha.", + "type": [ + "string", + "null" + ] + }, + "CommitsSinceVersionSource": { + "description": "The number of commits since the version source.", + "type": [ + "integer", + "null" + ] + }, + "CustomVersion": { + "description": "A custom version string, suitable for NuGet if format changed. Defaults to SemVer.", + "type": [ + "string", + "null" + ] + }, + "EscapedBranchName": { + "description": "Equal to BranchName, but with / replaced with -.", + "type": [ + "string", + "null" + ] + }, + "FullBuildMetaData": { + "description": "The BuildMetaData suffixed with BranchName and Sha.", + "type": [ + "string", + "null" + ] + }, + "FullSemVer": { + "description": "The full, SemVer 2.0 compliant version number.", + "type": [ + "string", + "null" + ] + }, + "InformationalVersion": { + "description": "Suitable for .NET AssemblyInformationalVersion. Defaults to FullSemVer suffixed by FullBuildMetaData.", + "type": [ + "string", + "null" + ] + }, + "Major": { + "description": "The major version. Should be incremented on breaking changes.", + "type": [ + "integer", + "null" + ] + }, + "MajorMinorPatch": { + "description": "Major, Minor and Patch joined together, separated by '.'.", + "type": [ + "string", + "null" + ] + }, + "Minor": { + "description": "The minor version. Should be incremented on new features.", + "type": [ + "integer", + "null" + ] + }, + "Patch": { + "description": "The patch version. Should be incremented on bug fixes.", + "type": [ + "integer", + "null" + ] + }, + "PreReleaseLabel": { + "description": "The pre-release label is the name of the pre-release.", + "type": [ + "string", + "null" + ] + }, + "PreReleaseLabelWithDash": { + "description": "The pre-release label prefixed with a dash.", + "type": [ + "string", + "null" + ] + }, + "PreReleaseNumber": { + "description": "The pre-release number is the number of commits since the last version bump.", + "type": [ + "integer", + "null" + ] + }, + "PreReleaseTag": { + "description": "The pre-release tag is the pre-release label suffixed by the PreReleaseNumber.", + "type": [ + "string", + "null" + ] + }, + "PreReleaseTagWithDash": { + "description": "The pre-release tag prefixed with a dash.", + "type": [ + "string", + "null" + ] + }, + "SemVer": { + "description": "The semantic version number, including PreReleaseTagWithDash for pre-release version numbers.", + "type": [ + "string", + "null" + ] + }, + "Sha": { + "description": "The SHA of the Git commit.", + "type": [ + "string", + "null" + ] + }, + "ShortSha": { + "description": "The Sha limited to 7 characters.", + "type": [ + "string", + "null" + ] + }, + "UncommittedChanges": { + "description": "The number of uncommitted changes present in the repository.", + "type": [ + "integer", + "null" + ] + }, + "VersionSourceSha": { + "description": "The SHA of the commit used as version source.", + "type": [ + "string", + "null" + ] + }, + "WeightedPreReleaseNumber": { + "description": "A summation of branch specific pre-release-weight and the PreReleaseNumber. Can be used to obtain a monotonically increasing version number across the branches.", + "type": [ + "integer", + "null" + ] + } + } +} \ No newline at end of file diff --git a/src/GitVersion.Configuration.Tests/Configuration/ConfigurationProviderTests.cs b/src/GitVersion.Configuration.Tests/Configuration/ConfigurationProviderTests.cs index 9ce9311f5b..8b619f80c3 100644 --- a/src/GitVersion.Configuration.Tests/Configuration/ConfigurationProviderTests.cs +++ b/src/GitVersion.Configuration.Tests/Configuration/ConfigurationProviderTests.cs @@ -421,6 +421,30 @@ public void ShouldUseDefaultTagPrefixWhenNotSetInConfigFile() configuration.TagPrefixPattern.ShouldBe(RegexPatterns.Configuration.DefaultTagPrefixRegexPattern); } + [Test] + public void ShouldUseCustomVersionFormatFromConfigFileWhenProvided() + { + const string text = "custom-version-format: custom-version-format-from-yml"; + using var _ = this.fileSystem.SetupConfigFile(path: this.repoPath, text: text); + var configuration = this.configurationProvider.ProvideForDirectory(this.repoPath); + + configuration.CustomVersionFormat.ShouldBe("custom-version-format-from-yml"); + } + + [Test] + public void ShouldOverrideCustomVersionFormatWithOverrideConfigValue([Values] bool customVersionFormatSetAtYmlFile) + { + var text = customVersionFormatSetAtYmlFile ? "custom-version-format: custom-version-format-from-yml" : ""; + using var _ = this.fileSystem.SetupConfigFile(path: this.repoPath, text: text); + var overrideConfiguration = new Dictionary + { + { "custom-version-format", "custom-version-from-override-configuration" } + }; + var configuration = this.configurationProvider.ProvideForDirectory(this.repoPath, overrideConfiguration); + + configuration.CustomVersionFormat.ShouldBe("custom-version-from-override-configuration"); + } + [Test] public void ShouldUseTagPrefixFromConfigFileWhenProvided() { diff --git a/src/GitVersion.Configuration/GitVersionConfiguration.cs b/src/GitVersion.Configuration/GitVersionConfiguration.cs index 6e3a49bf9c..f7c031a199 100644 --- a/src/GitVersion.Configuration/GitVersionConfiguration.cs +++ b/src/GitVersion.Configuration/GitVersionConfiguration.cs @@ -35,6 +35,11 @@ internal sealed record GitVersionConfiguration : BranchConfiguration, IGitVersio [JsonPropertyDescription("Specifies the format of AssemblyFileVersion and overwrites the value of assembly-file-versioning-scheme.")] public string? AssemblyFileVersioningFormat { get; internal init; } + [JsonPropertyName("custom-version-format")] + [JsonPropertyDescription($"Specifies the format of CustomVersion. Defaults to '{DefaultCustomVersionFormat}'.")] + [JsonPropertyDefault($"'{DefaultCustomVersionFormat}'")] + public string? CustomVersionFormat { get; internal init; } + [JsonPropertyName("tag-prefix")] [JsonPropertyDescription($"A regular expression which is used to trim Git tags before processing. Defaults to '{RegexPatterns.Configuration.DefaultTagPrefixRegexPattern}'")] [JsonPropertyDefault(RegexPatterns.Configuration.DefaultTagPrefixRegexPattern)] diff --git a/src/GitVersion.Core.Tests/Core/GitVersionExecutorTests.cs b/src/GitVersion.Core.Tests/Core/GitVersionExecutorTests.cs index 0852be5681..38064c58a4 100644 --- a/src/GitVersion.Core.Tests/Core/GitVersionExecutorTests.cs +++ b/src/GitVersion.Core.Tests/Core/GitVersionExecutorTests.cs @@ -117,6 +117,7 @@ public void CacheFileExistsOnDisk() "AssemblySemVer": "4.10.3.0", "AssemblySemFileVer": "4.10.3.0", "FullSemVer": "4.10.3-test.19", + "CustomVersion": "4.10.3.0", "InformationalVersion": "4.10.3-test.19+Branch.feature/test.Sha.dd2a29aff0c948e1bdf3dabbe13e1576e70d5f9f", "BranchName": "feature/test", "EscapedBranchName": "feature-test", @@ -180,6 +181,7 @@ public void CacheFileExistsOnDiskWhenOverrideConfigIsSpecifiedVersionShouldBeDyn "AssemblySemVer": "4.10.3.0", "AssemblySemFileVer": "4.10.3.0", "FullSemVer": "4.10.3-test.19", + "CustomVersion": "4.10.3.0", "InformationalVersion": "4.10.3-test.19+Branch.feature/test.Sha.dd2a29aff0c948e1bdf3dabbe13e1576e70d5f9f", "BranchName": "feature/test", "EscapedBranchName": "feature-test", @@ -271,6 +273,7 @@ public void ConfigChangeInvalidatesCache(string configFileName) "AssemblySemVer": "4.10.3.0", "AssemblySemFileVer": "4.10.3.0", "FullSemVer": "4.10.3-test.19", + "CustomVersion": "4.10.3.0", "InformationalVersion": "4.10.3-test.19+Branch.feature/test.Sha.dd2a29aff0c948e1bdf3dabbe13e1576e70d5f9f", "BranchName": "feature/test", "EscapedBranchName": "feature-test", @@ -333,6 +336,7 @@ public void NoCacheBypassesCache() "AssemblySemVer": "4.10.3.0", "AssemblySemFileVer": "4.10.3.0", "FullSemVer": "4.10.3-test.19", + "CustomVersion": "4.10.3.0", "InformationalVersion": "4.10.3-test.19+Branch.feature/test.Sha.dd2a29aff0c948e1bdf3dabbe13e1576e70d5f9f", "BranchName": "feature/test", "EscapedBranchName": "feature-test", diff --git a/src/GitVersion.Core.Tests/Helpers/TestableGitVersionVariables.cs b/src/GitVersion.Core.Tests/Helpers/TestableGitVersionVariables.cs index 5670ca86a3..0237f5b4ec 100644 --- a/src/GitVersion.Core.Tests/Helpers/TestableGitVersionVariables.cs +++ b/src/GitVersion.Core.Tests/Helpers/TestableGitVersionVariables.cs @@ -26,4 +26,5 @@ internal record TestableGitVersionVariables() : GitVersionVariables("", "", "", "", + "", ""); diff --git a/src/GitVersion.Core.Tests/VersionCalculation/Approved/JsonVersionBuilderTests.Json.approved.txt b/src/GitVersion.Core.Tests/VersionCalculation/Approved/JsonVersionBuilderTests.Json.approved.txt index 24061d9bfe..6f4efa6a09 100644 --- a/src/GitVersion.Core.Tests/VersionCalculation/Approved/JsonVersionBuilderTests.Json.approved.txt +++ b/src/GitVersion.Core.Tests/VersionCalculation/Approved/JsonVersionBuilderTests.Json.approved.txt @@ -9,6 +9,7 @@ "FullBuildMetaData": "5.Branch.feature1.Sha.commitSha", "FullSemVer": "1.2.0-unstable.4+5", "InformationalVersion": "1.2.0-unstable.4+5.Branch.feature1.Sha.commitSha", + "CustomVersion": "1.2.0-unstable.4", "Major": 1, "MajorMinorPatch": "1.2.0", "Minor": 2, diff --git a/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForFeatureBranch.approved.txt b/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForFeatureBranch.approved.txt index 2656e2afe4..7e5ee41004 100644 --- a/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForFeatureBranch.approved.txt +++ b/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForFeatureBranch.approved.txt @@ -9,6 +9,7 @@ "FullBuildMetaData": "5.Branch.feature-123.Sha.commitSha", "FullSemVer": "1.2.3+5", "InformationalVersion": "1.2.3+5.Branch.feature-123.Sha.commitSha", + "CustomVersion": "1.2.3", "Major": 1, "MajorMinorPatch": "1.2.3", "Minor": 2, diff --git a/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForFeatureBranchWithCustomAssemblyInfoFormat.approved.txt b/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForFeatureBranchWithCustomAssemblyInfoFormat.approved.txt index 55166aebe6..450cfe3080 100644 --- a/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForFeatureBranchWithCustomAssemblyInfoFormat.approved.txt +++ b/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForFeatureBranchWithCustomAssemblyInfoFormat.approved.txt @@ -9,6 +9,7 @@ "FullBuildMetaData": "5.Branch.feature-123.Sha.commitSha", "FullSemVer": "1.2.3+5", "InformationalVersion": "1.2.3+5.Branch.feature-123.Sha.commitShortSha", + "CustomVersion": "1.2.3", "Major": 1, "MajorMinorPatch": "1.2.3", "Minor": 2, diff --git a/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForPreRelease.approved.txt b/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForPreRelease.approved.txt index 4cc8738920..ee1db8d1c1 100644 --- a/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForPreRelease.approved.txt +++ b/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForPreRelease.approved.txt @@ -9,6 +9,7 @@ "FullBuildMetaData": "5.Branch.develop.Sha.commitSha", "FullSemVer": "1.2.3-unstable.4+5", "InformationalVersion": "1.2.3-unstable.4+5.Branch.develop.Sha.commitSha", + "CustomVersion": "1.2.3-unstable.4", "Major": 1, "MajorMinorPatch": "1.2.3", "Minor": 2, diff --git a/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForStable.approved.txt b/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForStable.approved.txt index 0b9c98e18a..dae11a1d6f 100644 --- a/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForStable.approved.txt +++ b/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForStable.approved.txt @@ -9,6 +9,7 @@ "FullBuildMetaData": "5.Branch.develop.Sha.commitSha", "FullSemVer": "1.2.3+5", "InformationalVersion": "1.2.3+5.Branch.develop.Sha.commitSha", + "CustomVersion": "1.2.3", "Major": 1, "MajorMinorPatch": "1.2.3", "Minor": 2, diff --git a/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForMainBranchWithEmptyLabel.approved.txt b/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForMainBranchWithEmptyLabel.approved.txt index f6bd57ef8f..8cae375b92 100644 --- a/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForMainBranchWithEmptyLabel.approved.txt +++ b/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForMainBranchWithEmptyLabel.approved.txt @@ -9,6 +9,7 @@ "FullBuildMetaData": "Branch.main.Sha.commitSha", "FullSemVer": "1.2.3-9", "InformationalVersion": "1.2.3-9+Branch.main.Sha.commitSha", + "CustomVersion": "1.2.3-9", "Major": 1, "MajorMinorPatch": "1.2.3", "Minor": 2, diff --git a/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForPreRelease.approved.txt b/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForPreRelease.approved.txt index 34ec2c613b..0347b46c79 100644 --- a/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForPreRelease.approved.txt +++ b/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForPreRelease.approved.txt @@ -9,6 +9,7 @@ "FullBuildMetaData": "Branch.develop.Sha.commitSha", "FullSemVer": "1.2.3-unstable.8", "InformationalVersion": "1.2.3-unstable.8+Branch.develop.Sha.commitSha", + "CustomVersion": "1.2.3-unstable.8", "Major": 1, "MajorMinorPatch": "1.2.3", "Minor": 2, diff --git a/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForStable.approved.txt b/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForStable.approved.txt index de207b299c..02f7a5c66d 100644 --- a/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForStable.approved.txt +++ b/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForStable.approved.txt @@ -9,6 +9,7 @@ "FullBuildMetaData": "Branch.develop.Sha.commitSha", "FullSemVer": "1.2.3-ci.5", "InformationalVersion": "1.2.3-ci.5+Branch.develop.Sha.commitSha", + "CustomVersion": "1.2.3-ci.5", "Major": 1, "MajorMinorPatch": "1.2.3", "Minor": 2, diff --git a/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForStableWhenCurrentCommitIsTagged.approved.txt b/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForStableWhenCurrentCommitIsTagged.approved.txt index 330accf021..758a0be072 100644 --- a/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForStableWhenCurrentCommitIsTagged.approved.txt +++ b/src/GitVersion.Core.Tests/VersionCalculation/Approved/VariableProviderTests.ProvidesVariablesInContinuousDeploymentModeForStableWhenCurrentCommitIsTagged.approved.txt @@ -9,6 +9,7 @@ "FullBuildMetaData": "5.Sha.commitSha", "FullSemVer": "1.2.3+5", "InformationalVersion": "1.2.3+5.Sha.commitSha", + "CustomVersion": "1.2.3", "Major": 1, "MajorMinorPatch": "1.2.3", "Minor": 2, diff --git a/src/GitVersion.Core/Configuration/ConfigurationConstants.cs b/src/GitVersion.Core/Configuration/ConfigurationConstants.cs index 017990354d..3f4dd7a638 100644 --- a/src/GitVersion.Core/Configuration/ConfigurationConstants.cs +++ b/src/GitVersion.Core/Configuration/ConfigurationConstants.cs @@ -23,6 +23,7 @@ internal static class ConfigurationConstants ]; public const string DefaultAssemblyInformationalFormat = "{InformationalVersion}"; public const string DefaultCommitDateFormat = "yyyy-MM-dd"; + public const string DefaultCustomVersionFormat = "{SemVer}"; public const string BranchNamePlaceholder = "{BranchName}"; public const string PullRequestNumberPlaceholder = "{Number}"; public const bool DefaultUpdateBuildNumber = true; diff --git a/src/GitVersion.Core/Configuration/IGitVersionConfiguration.cs b/src/GitVersion.Core/Configuration/IGitVersionConfiguration.cs index 1461d38034..a06039a46a 100644 --- a/src/GitVersion.Core/Configuration/IGitVersionConfiguration.cs +++ b/src/GitVersion.Core/Configuration/IGitVersionConfiguration.cs @@ -16,6 +16,8 @@ public interface IGitVersionConfiguration : IBranchConfiguration string? AssemblyFileVersioningFormat { get; } + string? CustomVersionFormat { get; } + string? TagPrefixPattern { get; } string? VersionInBranchPattern { get; } diff --git a/src/GitVersion.Core/OutputVariables/GitVersionVariables.cs b/src/GitVersion.Core/OutputVariables/GitVersionVariables.cs index 53a8b55172..86520a7551 100644 --- a/src/GitVersion.Core/OutputVariables/GitVersionVariables.cs +++ b/src/GitVersion.Core/OutputVariables/GitVersionVariables.cs @@ -21,6 +21,7 @@ public record GitVersionVariables(string Major, string? PreReleaseNumber, string WeightedPreReleaseNumber, string? InformationalVersion, + string? CustomVersion, string? CommitDate, string? VersionSourceSha, string? CommitsSinceVersionSource, @@ -49,6 +50,7 @@ public record GitVersionVariables(string Major, nameof(PreReleaseNumber), nameof(WeightedPreReleaseNumber), nameof(InformationalVersion), + nameof(CustomVersion), nameof(CommitDate), nameof(VersionSourceSha), nameof(CommitsSinceVersionSource), @@ -78,6 +80,7 @@ public record GitVersionVariables(string Major, { nameof(PreReleaseNumber), PreReleaseNumber }, { nameof(WeightedPreReleaseNumber), WeightedPreReleaseNumber }, { nameof(InformationalVersion), InformationalVersion }, + { nameof(CustomVersion), CustomVersion }, { nameof(CommitDate), CommitDate }, { nameof(VersionSourceSha), VersionSourceSha }, { nameof(CommitsSinceVersionSource), CommitsSinceVersionSource }, diff --git a/src/GitVersion.Core/PublicAPI.Shipped.txt b/src/GitVersion.Core/PublicAPI.Shipped.txt index 53c7d65518..a9b9c4d3b7 100644 --- a/src/GitVersion.Core/PublicAPI.Shipped.txt +++ b/src/GitVersion.Core/PublicAPI.Shipped.txt @@ -442,7 +442,6 @@ GitVersion.OutputVariables.GitVersionVariables.CommitDate.get -> string? GitVersion.OutputVariables.GitVersionVariables.CommitDate.init -> void GitVersion.OutputVariables.GitVersionVariables.CommitsSinceVersionSource.get -> string? GitVersion.OutputVariables.GitVersionVariables.CommitsSinceVersionSource.init -> void -GitVersion.OutputVariables.GitVersionVariables.Deconstruct(out string! Major, out string! Minor, out string! Patch, out string? BuildMetaData, out string? FullBuildMetaData, out string? BranchName, out string? EscapedBranchName, out string? Sha, out string? ShortSha, out string! MajorMinorPatch, out string! SemVer, out string! FullSemVer, out string? AssemblySemVer, out string? AssemblySemFileVer, out string? PreReleaseTag, out string? PreReleaseTagWithDash, out string? PreReleaseLabel, out string? PreReleaseLabelWithDash, out string? PreReleaseNumber, out string! WeightedPreReleaseNumber, out string? InformationalVersion, out string? CommitDate, out string? VersionSourceSha, out string? CommitsSinceVersionSource, out string? UncommittedChanges) -> void GitVersion.OutputVariables.GitVersionVariables.EscapedBranchName.get -> string? GitVersion.OutputVariables.GitVersionVariables.EscapedBranchName.init -> void GitVersion.OutputVariables.GitVersionVariables.FullBuildMetaData.get -> string? @@ -451,7 +450,6 @@ GitVersion.OutputVariables.GitVersionVariables.FullSemVer.get -> string! GitVersion.OutputVariables.GitVersionVariables.FullSemVer.init -> void GitVersion.OutputVariables.GitVersionVariables.GetEnumerator() -> System.Collections.Generic.IEnumerator>! GitVersion.OutputVariables.GitVersionVariables.GitVersionVariables(GitVersion.OutputVariables.GitVersionVariables! original) -> void -GitVersion.OutputVariables.GitVersionVariables.GitVersionVariables(string! Major, string! Minor, string! Patch, string? BuildMetaData, string? FullBuildMetaData, string? BranchName, string? EscapedBranchName, string? Sha, string? ShortSha, string! MajorMinorPatch, string! SemVer, string! FullSemVer, string? AssemblySemVer, string? AssemblySemFileVer, string? PreReleaseTag, string? PreReleaseTagWithDash, string? PreReleaseLabel, string? PreReleaseLabelWithDash, string? PreReleaseNumber, string! WeightedPreReleaseNumber, string? InformationalVersion, string? CommitDate, string? VersionSourceSha, string? CommitsSinceVersionSource, string? UncommittedChanges) -> void GitVersion.OutputVariables.GitVersionVariables.InformationalVersion.get -> string? GitVersion.OutputVariables.GitVersionVariables.InformationalVersion.init -> void GitVersion.OutputVariables.GitVersionVariables.Major.get -> string! diff --git a/src/GitVersion.Core/PublicAPI.Unshipped.txt b/src/GitVersion.Core/PublicAPI.Unshipped.txt index 7dc5c58110..a89ba4180d 100644 --- a/src/GitVersion.Core/PublicAPI.Unshipped.txt +++ b/src/GitVersion.Core/PublicAPI.Unshipped.txt @@ -1 +1,7 @@ #nullable enable +GitVersion.Configuration.IGitVersionConfiguration.CustomVersionFormat.get -> string? +GitVersion.OutputVariables.GitVersionVariables.Deconstruct(out string! Major, out string! Minor, out string! Patch, out string? BuildMetaData, out string? FullBuildMetaData, out string? BranchName, out string? EscapedBranchName, out string? Sha, out string? ShortSha, out string! MajorMinorPatch, out string! SemVer, out string! FullSemVer, out string? AssemblySemVer, out string? AssemblySemFileVer, out string? PreReleaseTag, out string? PreReleaseTagWithDash, out string? PreReleaseLabel, out string? PreReleaseLabelWithDash, out string? PreReleaseNumber, out string! WeightedPreReleaseNumber, out string? InformationalVersion, out string? CustomVersion, out string? CommitDate, out string? VersionSourceSha, out string? CommitsSinceVersionSource, out string? UncommittedChanges) -> void +GitVersion.OutputVariables.GitVersionVariables.GitVersionVariables(string! Major, string! Minor, string! Patch, string? BuildMetaData, string? FullBuildMetaData, string? BranchName, string? EscapedBranchName, string? Sha, string? ShortSha, string! MajorMinorPatch, string! SemVer, string! FullSemVer, string? AssemblySemVer, string? AssemblySemFileVer, string? PreReleaseTag, string? PreReleaseTagWithDash, string? PreReleaseLabel, string? PreReleaseLabelWithDash, string? PreReleaseNumber, string! WeightedPreReleaseNumber, string? InformationalVersion, string? CustomVersion, string? CommitDate, string? VersionSourceSha, string? CommitsSinceVersionSource, string? UncommittedChanges) -> void +GitVersion.OutputVariables.GitVersionVariables.CustomVersion.get -> string? +GitVersion.OutputVariables.GitVersionVariables.CustomVersion.init -> void +GitVersion.SemanticVersionFormatValues.CustomVersion.get -> string! diff --git a/src/GitVersion.Core/VersionCalculation/SemanticVersioning/SemanticVersionFormatValues.cs b/src/GitVersion.Core/VersionCalculation/SemanticVersioning/SemanticVersionFormatValues.cs index 64913a061c..c82b8d0370 100644 --- a/src/GitVersion.Core/VersionCalculation/SemanticVersioning/SemanticVersionFormatValues.cs +++ b/src/GitVersion.Core/VersionCalculation/SemanticVersioning/SemanticVersionFormatValues.cs @@ -52,6 +52,8 @@ public class SemanticVersionFormatValues(SemanticVersion semver, IGitVersionConf public string InformationalVersion => semver.ToString("i"); + public string CustomVersion => semver.ToString(); + public string? VersionSourceSha => semver.BuildMetaData.VersionSourceSha; public string CommitsSinceVersionSource => semver.BuildMetaData.CommitsSinceVersionSource.ToString(CultureInfo.InvariantCulture); diff --git a/src/GitVersion.Core/VersionCalculation/VariableProvider.cs b/src/GitVersion.Core/VersionCalculation/VariableProvider.cs index 424c91711b..db52fa5097 100644 --- a/src/GitVersion.Core/VersionCalculation/VariableProvider.cs +++ b/src/GitVersion.Core/VersionCalculation/VariableProvider.cs @@ -25,6 +25,13 @@ public GitVersionVariables GetVariablesFor( "AssemblyInformationalVersion" ); + var customVersion = CheckAndFormatString( + configuration.CustomVersionFormat, + semverFormatValues, + semverFormatValues.CustomVersion, + "CustomVersion" + ); + var assemblyFileSemVer = CheckAndFormatString( configuration.AssemblyFileVersioningFormat, semverFormatValues, @@ -61,6 +68,7 @@ public GitVersionVariables GetVariablesFor( semverFormatValues.PreReleaseNumber, semverFormatValues.WeightedPreReleaseNumber, informationalVersion, + customVersion, semverFormatValues.CommitDate, semverFormatValues.VersionSourceSha, semverFormatValues.CommitsSinceVersionSource, diff --git a/src/GitVersion.MsBuild/PublicAPI.Unshipped.txt b/src/GitVersion.MsBuild/PublicAPI.Unshipped.txt index 7dc5c58110..7d8ec75e7f 100644 --- a/src/GitVersion.MsBuild/PublicAPI.Unshipped.txt +++ b/src/GitVersion.MsBuild/PublicAPI.Unshipped.txt @@ -1 +1,3 @@ #nullable enable +GitVersion.MsBuild.Tasks.GetVersion.CustomVersion.get -> string! +GitVersion.MsBuild.Tasks.GetVersion.CustomVersion.set -> void diff --git a/src/GitVersion.MsBuild/Tasks/GetVersion.cs b/src/GitVersion.MsBuild/Tasks/GetVersion.cs index 2a3e695a99..2d33ea775b 100644 --- a/src/GitVersion.MsBuild/Tasks/GetVersion.cs +++ b/src/GitVersion.MsBuild/Tasks/GetVersion.cs @@ -55,6 +55,9 @@ public class GetVersion : GitVersionTaskBase [Output] public string InformationalVersion { get; set; } + [Output] + public string CustomVersion { get; set; } + [Output] public string BranchName { get; set; } diff --git a/src/GitVersion.Output.Tests/Output/Approved/WixFileTests.UpdateWixVersionFile.approved.txt b/src/GitVersion.Output.Tests/Output/Approved/WixFileTests.UpdateWixVersionFile.approved.txt index d935478f68..15f70e68b9 100644 --- a/src/GitVersion.Output.Tests/Output/Approved/WixFileTests.UpdateWixVersionFile.approved.txt +++ b/src/GitVersion.Output.Tests/Output/Approved/WixFileTests.UpdateWixVersionFile.approved.txt @@ -6,6 +6,7 @@ + diff --git a/src/GitVersion.Output.Tests/Output/Approved/WixFileTests.UpdateWixVersionFileWhenFileAlreadyExists.approved.txt b/src/GitVersion.Output.Tests/Output/Approved/WixFileTests.UpdateWixVersionFileWhenFileAlreadyExists.approved.txt index d935478f68..15f70e68b9 100644 --- a/src/GitVersion.Output.Tests/Output/Approved/WixFileTests.UpdateWixVersionFileWhenFileAlreadyExists.approved.txt +++ b/src/GitVersion.Output.Tests/Output/Approved/WixFileTests.UpdateWixVersionFileWhenFileAlreadyExists.approved.txt @@ -6,6 +6,7 @@ + diff --git a/src/GitVersion.Output.Tests/Output/Approved/cs/GitVersionInfoGeneratorTests.ShouldCreateFile.approved.txt b/src/GitVersion.Output.Tests/Output/Approved/cs/GitVersionInfoGeneratorTests.ShouldCreateFile.approved.txt index 1289bd4dc8..9ab28983d6 100644 --- a/src/GitVersion.Output.Tests/Output/Approved/cs/GitVersionInfoGeneratorTests.ShouldCreateFile.approved.txt +++ b/src/GitVersion.Output.Tests/Output/Approved/cs/GitVersionInfoGeneratorTests.ShouldCreateFile.approved.txt @@ -18,6 +18,7 @@ static class GitVersionInformation public const string BuildMetaData = "5"; public const string CommitDate = "2014-03-06"; public const string CommitsSinceVersionSource = "5"; + public const string CustomVersion = "1.2.3-unstable.4"; public const string EscapedBranchName = "feature1"; public const string FullBuildMetaData = "5.Branch.feature1.Sha.commitSha"; public const string FullSemVer = "1.2.3-unstable.4+5"; diff --git a/src/GitVersion.Output.Tests/Output/Approved/cs/GitVersionInfoGeneratorTests.ShouldProperlyOutputNamespaceDeclaration.approved.txt b/src/GitVersion.Output.Tests/Output/Approved/cs/GitVersionInfoGeneratorTests.ShouldProperlyOutputNamespaceDeclaration.approved.txt index 8cb6fbe737..f1c3ec94ff 100644 --- a/src/GitVersion.Output.Tests/Output/Approved/cs/GitVersionInfoGeneratorTests.ShouldProperlyOutputNamespaceDeclaration.approved.txt +++ b/src/GitVersion.Output.Tests/Output/Approved/cs/GitVersionInfoGeneratorTests.ShouldProperlyOutputNamespaceDeclaration.approved.txt @@ -20,6 +20,7 @@ namespace My.Custom.Namespace public const string BuildMetaData = "5"; public const string CommitDate = "2014-03-06"; public const string CommitsSinceVersionSource = "5"; + public const string CustomVersion = "1.2.3-unstable.4"; public const string EscapedBranchName = "feature1"; public const string FullBuildMetaData = "5.Branch.feature1.Sha.commitSha"; public const string FullSemVer = "1.2.3-unstable.4+5"; diff --git a/src/GitVersion.Output.Tests/Output/Approved/fs/GitVersionInfoGeneratorTests.ShouldCreateFile.approved.txt b/src/GitVersion.Output.Tests/Output/Approved/fs/GitVersionInfoGeneratorTests.ShouldCreateFile.approved.txt index f653c20b31..14c8385b11 100644 --- a/src/GitVersion.Output.Tests/Output/Approved/fs/GitVersionInfoGeneratorTests.ShouldCreateFile.approved.txt +++ b/src/GitVersion.Output.Tests/Output/Approved/fs/GitVersionInfoGeneratorTests.ShouldCreateFile.approved.txt @@ -20,6 +20,7 @@ type GitVersionInformation = static member BuildMetaData = "5" static member CommitDate = "2014-03-06" static member CommitsSinceVersionSource = "5" + static member CustomVersion = "1.2.3-unstable.4" static member EscapedBranchName = "feature1" static member FullBuildMetaData = "5.Branch.feature1.Sha.commitSha" static member FullSemVer = "1.2.3-unstable.4+5" diff --git a/src/GitVersion.Output.Tests/Output/Approved/fs/GitVersionInfoGeneratorTests.ShouldProperlyOutputNamespaceDeclaration.approved.txt b/src/GitVersion.Output.Tests/Output/Approved/fs/GitVersionInfoGeneratorTests.ShouldProperlyOutputNamespaceDeclaration.approved.txt index ac564fb232..5e75b403bf 100644 --- a/src/GitVersion.Output.Tests/Output/Approved/fs/GitVersionInfoGeneratorTests.ShouldProperlyOutputNamespaceDeclaration.approved.txt +++ b/src/GitVersion.Output.Tests/Output/Approved/fs/GitVersionInfoGeneratorTests.ShouldProperlyOutputNamespaceDeclaration.approved.txt @@ -20,6 +20,7 @@ type GitVersionInformation = static member BuildMetaData = "5" static member CommitDate = "2014-03-06" static member CommitsSinceVersionSource = "5" + static member CustomVersion = "1.2.3-unstable.4" static member EscapedBranchName = "feature1" static member FullBuildMetaData = "5.Branch.feature1.Sha.commitSha" static member FullSemVer = "1.2.3-unstable.4+5" diff --git a/src/GitVersion.Output.Tests/Output/Approved/vb/GitVersionInfoGeneratorTests.ShouldCreateFile.approved.txt b/src/GitVersion.Output.Tests/Output/Approved/vb/GitVersionInfoGeneratorTests.ShouldCreateFile.approved.txt index 91cb09fa24..ced0c0e148 100644 --- a/src/GitVersion.Output.Tests/Output/Approved/vb/GitVersionInfoGeneratorTests.ShouldCreateFile.approved.txt +++ b/src/GitVersion.Output.Tests/Output/Approved/vb/GitVersionInfoGeneratorTests.ShouldCreateFile.approved.txt @@ -21,6 +21,7 @@ Namespace Global Public Shared BuildMetaData As String = "5" Public Shared CommitDate As String = "2014-03-06" Public Shared CommitsSinceVersionSource As String = "5" + Public Shared CustomVersion As String = "1.2.3-unstable.4" Public Shared EscapedBranchName As String = "feature1" Public Shared FullBuildMetaData As String = "5.Branch.feature1.Sha.commitSha" Public Shared FullSemVer As String = "1.2.3-unstable.4+5" diff --git a/src/GitVersion.Output.Tests/Output/Approved/vb/GitVersionInfoGeneratorTests.ShouldProperlyOutputNamespaceDeclaration.approved.txt b/src/GitVersion.Output.Tests/Output/Approved/vb/GitVersionInfoGeneratorTests.ShouldProperlyOutputNamespaceDeclaration.approved.txt index f1fc481aaa..8b363bea2e 100644 --- a/src/GitVersion.Output.Tests/Output/Approved/vb/GitVersionInfoGeneratorTests.ShouldProperlyOutputNamespaceDeclaration.approved.txt +++ b/src/GitVersion.Output.Tests/Output/Approved/vb/GitVersionInfoGeneratorTests.ShouldProperlyOutputNamespaceDeclaration.approved.txt @@ -21,6 +21,7 @@ Namespace My.Custom.Namespace Public Shared BuildMetaData As String = "5" Public Shared CommitDate As String = "2014-03-06" Public Shared CommitsSinceVersionSource As String = "5" + Public Shared CustomVersion As String = "1.2.3-unstable.4" Public Shared EscapedBranchName As String = "feature1" Public Shared FullBuildMetaData As String = "5.Branch.feature1.Sha.commitSha" Public Shared FullSemVer As String = "1.2.3-unstable.4+5" diff --git a/src/GitVersion.Output/Serializer/VersionVariablesJsonModel.cs b/src/GitVersion.Output/Serializer/VersionVariablesJsonModel.cs index 89d32b254b..ba46f11a21 100644 --- a/src/GitVersion.Output/Serializer/VersionVariablesJsonModel.cs +++ b/src/GitVersion.Output/Serializer/VersionVariablesJsonModel.cs @@ -34,6 +34,9 @@ internal class VersionVariablesJsonModel [JsonPropertyDescription("Suitable for .NET AssemblyInformationalVersion. Defaults to FullSemVer suffixed by FullBuildMetaData.")] public string? InformationalVersion { get; set; } + [JsonPropertyDescription("A custom version, suitable for package managers, e.g. NuGet, with appropriate formatting. Defaults to SemVer.")] + public string? CustomVersion { get; set; } + [JsonPropertyDescription("The major version. Should be incremented on breaking changes.")] public int? Major { get; set; }