Skip to content

[Bug] Resolving SemVer fail with an empty tag in a configuration branch #3218

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

Closed
enriqueraso opened this issue Oct 4, 2022 · 3 comments · Fixed by #3224
Closed

[Bug] Resolving SemVer fail with an empty tag in a configuration branch #3218

enriqueraso opened this issue Oct 4, 2022 · 3 comments · Fixed by #3224
Labels
Milestone

Comments

@enriqueraso
Copy link
Contributor

enriqueraso commented Oct 4, 2022

Describe the bug
GitVersion is not replacing semver when configuration branch has an empty tag. But it is doing the replacement when the configuration branch has a non-empty tag.

Expected Behavior

GitVersion should replace semver when you have an empty tag defined in the configuration branch, and it should not replace when you do not have a tag defined in the configuration branch.

Actual Behavior

GitVersion it is not replacing semver when you have an empty tag defined in the configuration branch.

Possible Fix

After debugged it, it only requires to fix how branchConfigHasPreReleaseTagConfigured is calculated in method FindVersion of NextVersionCalculator class.

// var branchConfigHasPreReleaseTagConfigured = !tag.IsNullOrEmpty();
var branchConfigHasPreReleaseTagConfigured = (tag != null);

Steps to Reproduce

GitVersion.Tool 5.10.3 installed on local.

Content of gitversion.yml

next-version: 1.0.0
assembly-versioning-scheme: MajorMinorPatch
assembly-file-versioning-scheme: MajorMinorPatch
assembly-informational-format: '{InformationalVersion}'
mode: ContinuousDelivery
branches: 
  main:
    regex: ^main$
    tag: rc
    increment: None
    is-source-branch-for:
    - bug
    - feature
    prevent-increment-of-merged-branch-version: true
    track-merge-target: false
    tracks-release-branches: false
    is-release-branch: false
    is-mainline: true
    pre-release-weight: 55000
  release:
    regex: ^releases/
    tag: ''
    increment: Inherit
    source-branches:
    - main
    is-source-branch-for:
    - retrofit-bug
    - retrofit-feature
    prevent-increment-of-merged-branch-version: false
    track-merge-target: false
    tracks-release-branches: false
    is-release-branch: true
    is-mainline: true
    pre-release-weight: 55000
  pull-request:
    regex: ^pull[/-]
    tag: 'beta.{BranchName}'
    increment: Inherit
    source-branches:
    - retrofit-bug
    - retrofit-feature
    - bug
    - feature
    prevent-increment-of-merged-branch-version: false
    track-merge-target: false
    tracks-release-branches: false
    is-release-branch: false
    is-mainline: false
    pre-release-weight: 30000
  retrofit-bug:
    regex: ^retrofit/bugs[/-]
    tag: beta.{BranchName}
    increment: Patch
    source-branches: 
    - release
    prevent-increment-of-merged-branch-version: false
    track-merge-target: true
    tracks-release-branches: false
    is-release-branch: false
    is-mainline: false
    pre-release-weight: 30000
  retrofit-feature:
    regex: ^retrofit[/-]
    tag: beta.{BranchName}
    increment: Minor
    source-branches:
    - release
    prevent-increment-of-merged-branch-version: false
    track-merge-target: true
    tracks-release-branches: false
    is-release-branch: false
    is-mainline: false
    pre-release-weight: 30000
  bug:
    regex: ^bugs[/-]
    tag: beta.{BranchName}
    increment: None
    source-branches:
    - main
    prevent-increment-of-merged-branch-version: false
    track-merge-target: false
    tracks-release-branches: false
    is-release-branch: false
    is-mainline: false
    pre-release-weight: 30000
  feature:
    regex: ^(?!.*main)(?!.*releases)(?!.*pull)(?!.*retrofit)(?!.*bugs).*
    tag: beta.{BranchName}
    increment: None
    source-branches:
    - main
    prevent-increment-of-merged-branch-version: false
    track-merge-target: false
    tracks-release-branches: false
    is-release-branch: false
    is-mainline: false
    pre-release-weight: 30000
ignore:
  sha: []
merge-message-formats: {}
  1. Create a commit on main branch and tag it 1.14.0-rc.
  2. Create releases/1 branch.
  3. Run gitversion and it will return 1.14.0-rc. It is expected to have 1.14.0 as you can see in the configuration, but it returns based on tag in main branch because it doesn't consider as a configured tag when you define an empty string tag.
    image
  4. Update tag in release branch configuration to abc and run gitversion. It will return 1.14.0-abc. In this case, it is considering tag configured as it has a non-empty value.
    image

Context

Can not have releases/1 branch created from main branch with a tag 1.14.0-rc. It obliges to have releases/1.14 and don't increase Minor.

This fix will also solve open bug #3060

@enriqueraso enriqueraso added the bug label Oct 4, 2022
@asbjornu
Copy link
Member

Pull requests are welcome. Please have a look at @AlexPykavy's work in #3208 as it seems to be related.

@asbjornu asbjornu linked a pull request Jan 20, 2023 that will close this issue
5 tasks
@asbjornu asbjornu added this to the 5.x milestone Jan 20, 2023
@arturcic
Copy link
Member

Closed by #3224

@arturcic arturcic modified the milestones: 5.x, 5.12.0 Jan 20, 2023
@arturcic
Copy link
Member

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

Your GitReleaseManager bot 📦🚀

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.

3 participants