GitVersion icon indicating copy to clipboard operation
GitVersion copied to clipboard

Enable support for {Sha} and {ShortSha} variables inside tag property

Open rdanilin opened this issue 3 years ago • 4 comments

Is your improvement request related to a problem? Please describe.

It would be nice to have a support for {Sha} / {ShortSha} variables inside 'tag' property in GitVersion.yml.

Detailed Description

I'm trying to generate a version which contains a commit hash, but seems like that does not support by GitVersion tool.

Below my configuration and output:

mode: ContinuousDelivery
branches:
  develop:
    tag: ''
    regex: ^develop
  feature:
    regex: ^feature[/-]
    tag: 'ci.{ShortSha}'

Output:

{
  "Major": 1,
  "Minor": 1,
  "Patch": 0,
  "PreReleaseTag": "ci.{ShortSha}.1",
  "PreReleaseTagWithDash": "-ci.{ShortSha}.1",
  "PreReleaseLabel": "ci.{ShortSha}",
  "PreReleaseLabelWithDash": "-ci.{ShortSha}",
  "PreReleaseNumber": 1,
  "WeightedPreReleaseNumber": 30001,
  "BuildMetaData": 1,
  "BuildMetaDataPadded": "0001",
  "FullBuildMetaData": "1.Branch.feature-my-feature.Sha.bab86bbaa91a9d09a53c4f8767d5cf6be05ac4eb",
  "MajorMinorPatch": "1.1.0",
  "SemVer": "1.1.0-ci.{ShortSha}.1",
  "LegacySemVer": "1.1.0-ci{ShortSha}1",
  "LegacySemVerPadded": "1.1.0-ci{ShortSha}0001",
  "AssemblySemVer": "1.1.0.0",
  "AssemblySemFileVer": "1.1.0.0",
  "FullSemVer": "1.1.0-ci.{ShortSha}.1+1",
  "InformationalVersion": "1.1.0-ci.{ShortSha}.1+1.Branch.feature-my-feature.Sha.bab86bbaa91a9d09a53c4f8767d5cf6be05ac4eb",
  "BranchName": "feature/my-feature",
  "EscapedBranchName": "feature-my-feature",
  "Sha": "bab86bbaa91a9d09a53c4f8767d5cf6be05ac4eb",
  "ShortSha": "bab86bb",
  "NuGetVersionV2": "1.1.0-ci{shortsha}0001",
  "NuGetVersion": "1.1.0-ci{shortsha}0001",
  "NuGetPreReleaseTagV2": "ci{shortsha}0001",
  "NuGetPreReleaseTag": "ci{shortsha}0001",
  "VersionSourceSha": "3522c8f7d00f0607a3e096c8752870599cab2c8f",
  "CommitsSinceVersionSource": 1,
  "CommitsSinceVersionSourcePadded": "0001",
  "UncommittedChanges": 0,
  "CommitDate": "2022-03-07"
}

rdanilin avatar Mar 07 '22 21:03 rdanilin

#2179 added support for formatting GitVersion properties, but custom formatting is reserved for the various -format configuration properties and is not supported in tag. Adding a tag-format property may be up for discussion, though.

asbjornu avatar Mar 07 '22 22:03 asbjornu

This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs.

github-actions[bot] avatar Mar 04 '23 09:03 github-actions[bot]

I would love to see this feature. We are versioning using the shortsha on our feature branches currently and it would be great if gitversion SemVer could be configured to return 1.2.3 on main and 1.2.3-shortsha on feature.

Looks like if this was supported I would still be getting a PreReleaseNumber tacked on the end. Not sure if there is anyway to format the PreReleaseTag to return just {MajorMinorPatch}-{ShortSha}

waderobson avatar Jun 28 '23 17:06 waderobson

This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs.

github-actions[bot] avatar Sep 29 '23 11:09 github-actions[bot]