Skip to content

[Feature] Support release branch naming with MAJOR SemVer number only #2679

Closed
@RobSmyth

Description

@RobSmyth

Support base version extraction from branch naming with just the number.

Detailed Description

Currently GitVersion does work with our branch naming convention which has release branch naming format:

release/<MAJOR>

The major portion of the base version number is not discovered from branches in a typical repository like:

release/0
release/1
release/2 ...

When we create a new release branch the version number (e.g. release/1 -> 1.0.0) is not picked up and a tag of v1 does not work either. However release/1.0 and a tag v1.0 do work.

Context

The change would allow GitVersion to be used without our branch numbering convention. This convention works well for us as we are daily adding bug fixes and/or features with a fairly short release cycle. Major version bumps are infrequent and result in customer code that is affectively orphaned and requires separate handling, so this branch name works very well for us.

Possible Implementation

Changing the text parsing in SemanticVersion to handle only such as 3 -> 3.0.0 looks like it would fix the problem.

I'm unable to build the code to test, but a fix looks like changing the regex in SemanticVersion to:

private static readonly Regex ParseSemVer = new Regex( @"^(?<SemVer>(?<Major>\d+)(\.(?<Minor>\d+))?(\.(?<Patch>\d+))?)(\.(?<FourthPart>\d+))?(-(?<Tag>[^\+]*))?(\+(?<BuildMetaData>.*))?$", RegexOptions.Compiled);

And add the test case to SemanticVersionTests.ValidateVersionParsing:

[TestCase("1", 1, 0, 0, null, null, null, null, null, null, null, null)]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions