Skip to content

[Improvement] Allow for a pre-release tag with just a number, without name #2235

@carlos-vicente

Description

@carlos-vicente

Is your improvement request related to a problem? Please describe.
It would be great to allow for a pre-release tag with just a number, I believe the name should not be mandatory for a correct pre-release tag.

Detailed Description

Currently we have a repo where we've been using git flow for a while now and are introducing a better versioning system with gitversion.
The release branches have the following naming: release/Release-X.Y, initially tagged with Release-X.Y.0-0, meaning this is our release candidate 0 for release X.Y.0. Each bugfix we introduce into the release branch gets tagged with Release-X.Y.0-1, Release-X.Y.0-2, Release-X.Y.0-3 and so forth.

With this configuration:

mode: ContinuousDelivery
tag-prefix: '[Rr]elease-'
assembly-versioning-scheme: MajorMinorPatchTag
assembly-file-versioning-scheme: MajorMinorPatchTag
ignore:
  sha: []
merge-message-formats: {}

Using dotnet-gitversion on version:

dotnet-gitversion /version
5.1.3+Branch.master.Sha.bef8ebc0b62b3ddd0cdafe09b66d68bbfcaf90d5

(also tested with latest version with the same result)

When getting the version on the release branches, with those tags, this is what we get (some fields omitted):

{
  "Major":5,
  "Minor":13,
  "Patch":0,
  "PreReleaseTag":".10",
  "PreReleaseTagWithDash":"",
  "PreReleaseLabel":"",
  "PreReleaseNumber":"",
  "WeightedPreReleaseNumber":"",
  "BuildMetaData":"",
  "BuildMetaDataPadded":"",
  "MajorMinorPatch":"5.13.0",
  "SemVer":"5.13.0",
  "LegacySemVer":"5.13.0",
  "LegacySemVerPadded":"5.13.0",
  "AssemblySemVer":"5.13.0.10",
  "AssemblySemFileVer":"5.13.0.10",
  "FullSemVer":"5.13.0",
}

this is what we expected to get:

{
  "Major":5,
  "Minor":13,
  "Patch":0,
  "PreReleaseTag":10,
  "PreReleaseTagWithDash":-10,
  "PreReleaseLabel":"",
  "PreReleaseNumber":10,
  "WeightedPreReleaseNumber":10,
  "BuildMetaData":"",
  "BuildMetaDataPadded":"",
  "MajorMinorPatch":"5.13.0",
  "SemVer":"5.13.0-10",
  "LegacySemVer":"5.13.0-10",
  "LegacySemVerPadded":"5.13.0-0010",
  "AssemblySemVer":"5.13.0.10",
  "AssemblySemFileVer":"5.13.0.10",
  "FullSemVer":"5.13.0-10",
}

Context

This is very important to us as it would prevent us from adding a name to the pre-release tag we do not need. As defined in https://semver.org/#spec-item-9 the pre-release identifier can be just numeric.

Possible Implementation

From my investigations the pre-release tag parsing is already supporting this, the only change required would be to checking that a pre-release part has in fact a tag and allowing for a correct formatting. I've forked the repo and made such modifications (https://github.com/carlos-vicente/GitVersion), opening this issue before the PR to get your thoughts on this.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions