- 
                Notifications
    
You must be signed in to change notification settings  - Fork 661
 
Description
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: {}- Create a commit on main branch and tag it 
1.14.0-rc. - Create 
releases/1branch. - Run gitversion and it will return 
1.14.0-rc. It is expected to have1.14.0as 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.

 - Update tag in release branch configuration to 
abcand run gitversion. It will return1.14.0-abc. In this case, it is considering tag configured as it has a non-empty value.

 
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