[Bug] Hotfix branch name not taken as version source
Describe the bug In documentation: https://gitversion.net/docs/more-info/version-increments, at point Branch name it's mentioned that the version in Hotfix branch name should be taken as version source. It's not working. Was behavior changed and not documented?
Expected Behavior
In case there is version in hotfix branch e.g. hotfix/4.21.1, the version 4.21.1 should be taken as version source.
Actual Behavior
The version in branch name is not taken into consideration when calculating version. Version calculated is lower than expected.
Possible Fix
From what I can see in VersionInBranchNameVersionStrategy class, the version is taken only from Release branches based on is-release-branch flag in GitVersion config. It could be extended to check if a branch is hotfix with Regex, then try to get version from branch name.
Steps to Reproduce
Submitted Test Case scenario. https://github.com/GitTools/GitVersion/pull/2337
Context
When creating hotfix branch for a bug in a release, I expect to build the branch with same version as release. As I have read documentation, I could achieve it with including version in a branch name. Except it doesn't work. It calculates version lower than the Release version, cause it doesn't take version from branch name.
Your Environment
- Version Used: 5.3.6
- Operating System and version (Windows 10, Ubuntu 18.04): Windows 10
- Link to your project:
- Link to your CI build (if appropriate):
What happens if you configure hotfix branches with is-release-branch: true?
@asbjornu If the is-release-branch: true is set for Hotfix branches, it works. It's a solution, but I wonder if there are any other effects of setting Hotfix branches as releases? Looking at the documentation it seemed like that behavior would be out of the box, is it intentional to work only after setting the flag?
I assume this behaviour was changed in #1541, where before, numbers in branch names were accidentally interpreted as version numbers, causing trouble all over the place. Hotfix branches should probably be considered release branches by default, though. Would you be up for submitting a PR with this default configuration change?
I can take a look and try to make the change. Probably by the end of the week, when I have free time.
@asbjornu I made the change to default configuration and adjusted/added the test scenarios to the it. PR can be seen at https://github.com/GitTools/GitVersion/pull/2346. It seems that with this change handling of merge messages of Hotfix branches will be changed as well. There were several test scenarios where it was expected that Hotfix branch merges should not be taken into consideration in version calculation, what do you think about it?
Great, I'll take a look at the PR.
This issue is related to https://github.com/GitTools/GitVersion/pull/2442 - merging release/hotfix branch to master.
Would it be possible to submit a PR with a test that demonstrates this problem, if it still exists?
Has been resolved with PR https://github.com/GitTools/GitVersion/issues/2336 without the need of specifing IsRelease to true for Hotfix branches.
:tada: This issue has been resolved in version 6.0.0-beta.1 :tada: The release is available on:
Your GitReleaseManager bot :package::rocket: