-
Notifications
You must be signed in to change notification settings - Fork 654
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
Fix issue with empty prerelease tags. #3224
Fix issue with empty prerelease tags. #3224
Conversation
@asbjornu I checked my bug #3218 with proposal PR #3208 applying the changes in Config.cs and SemanticVersion.cs, and it doesn't work. GitVersion continues returning PR #3208 is related to The image below shows result from GitVersion with changes from PR #3208 and from GitVersion with my PR. So, my PR solved another issue reported in bugs #3223 and #3060 |
@@ -116,6 +126,12 @@ private void UpdatePreReleaseTag(EffectiveConfiguration configuration, SemanticV | |||
{ | |||
var tagToUse = configuration.GetBranchSpecificTag(this.log, Context.CurrentBranch.Name.Friendly, branchNameOverride); | |||
|
|||
if (configuration.IsMainline && tagToUse.IsEmpty()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why only in that case the branch is set to IsMainline=true?
@@ -80,8 +80,12 @@ public NextVersion FindVersion() | |||
var hasPreReleaseTag = semver.PreReleaseTag?.HasTag() == true; | |||
var tag = configuration.Value.Tag; | |||
var branchConfigHasPreReleaseTagConfigured = !tag.IsNullOrEmpty(); | |||
var preReleaseTagDoesNotMatchConfiguration = hasPreReleaseTag && branchConfigHasPreReleaseTagConfigured && semver.PreReleaseTag?.Name != tag; | |||
if (semver.PreReleaseTag?.HasTag() != true && branchConfigHasPreReleaseTagConfigured || preReleaseTagDoesNotMatchConfiguration) | |||
var branchConfigIsMainlineAndHasEmptyPreReleaseTagConfigured = configuration.Value.IsMainline && tag.IsEmpty(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised that this logic is so complex why not keep it simple and refactor the expression like:
var expectedTag = configuration.GetBranchSpecificTag(this.log, Context.CurrentBranch.Name.Friendly, branchNameOverride);
var actualTag = semver.PreReleaseTag?.Name ?? string.Empty;
var preReleaseTagDoesNotMatchConfiguration = actualTag != expectedTag;
if(preReleaseTagDoesNotMatchConfiguration)
{
UpdatePreReleaseTag(configuration.Value, semver, expectedTag);
}
…gured to update prerelease tag in semver
ae8500f
to
3a6b123
Compare
Thank you @enriqueraso for your contribution! |
Merge pull request #3224 from enriqueraso/bug/resolving-semver-fail-with-an-empty-tag-in-a-configuration-branch Fix issue with empty prerelease tags.
Merge pull request #3224 from enriqueraso/bug/resolving-semver-fail-with-an-empty-tag-in-a-configuration-branch Fix issue with empty prerelease tags.
Fix issue when you have an empty tag configured in your branch defined as mainline.
Description
Basically, the changes are related to detect if branchConfig is Mainline and has empty prerelease tag configured on it, then it will update prerelease tag in semver.
I created the branch from support/5.x
Related Issue
Fix #3218
Motivation and Context
I want to use GitVersion in Azure DevOps with the gitversion.yml described in the bug.
Also, gitversion.yml of the documentation has configured empty prerelease tag and mainline for main and support/* branches.
How Has This Been Tested?
I tested locally and from the Azure DevOps.
Checklist: