Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
RobSmyth opened this issue May 6, 2021 · 6 comments · Fixed by #2699
Closed

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

RobSmyth opened this issue May 6, 2021 · 6 comments · Fixed by #2699
Labels
Milestone

Comments

@RobSmyth
Copy link

RobSmyth commented May 6, 2021

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)]

@asbjornu
Copy link
Member

asbjornu commented May 6, 2021

I agree this should be supported. Pull requests are welcome.

@RobSmyth
Copy link
Author

RobSmyth commented May 7, 2021

I'm currently unable to build GitVersion.MsBuild so I cannot test my suggested change (add "?" to ParseSemVer regex). That is an inhibitor to my raising a PR.

@mglochsen
Copy link
Contributor

As I'm interested in this feature as well, I created a PR with the suggested changes.

asbjornu added a commit that referenced this issue May 20, 2021
…aming-with-major-only

(GH-2679) Support release branch naming with MAJOR SemVer number only
@asbjornu asbjornu added this to the 5.6.10 milestone May 20, 2021
@RobSmyth
Copy link
Author

Thank you. Sorry for late response, I have been away.

@github-actions
Copy link

🎉 This issue has been resolved in version 5.6.10 🎉
The release is available on:

Your GitReleaseManager bot 📦🚀

@novasdream
Copy link

novasdream commented Jun 8, 2021

it will conflict if you have something like

release/test-build-23

it will set your major to 23

you will not able to set back using your tags.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants