GitVersion icon indicating copy to clipboard operation
GitVersion copied to clipboard

[Bug] Hotfix branch name not taken as version source

Open dramdrung opened this issue 5 years ago • 8 comments

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

dramdrung avatar Jun 23 '20 09:06 dramdrung

What happens if you configure hotfix branches with is-release-branch: true?

asbjornu avatar Jun 23 '20 13:06 asbjornu

@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?

dramdrung avatar Jun 23 '20 14:06 dramdrung

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?

asbjornu avatar Jun 23 '20 14:06 asbjornu

I can take a look and try to make the change. Probably by the end of the week, when I have free time.

dramdrung avatar Jun 24 '20 07:06 dramdrung

@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?

dramdrung avatar Jul 02 '20 17:07 dramdrung

Great, I'll take a look at the PR.

asbjornu avatar Jul 02 '20 23:07 asbjornu

This issue is related to https://github.com/GitTools/GitVersion/pull/2442 - merging release/hotfix branch to master.

pi3k14 avatar Nov 04 '20 06:11 pi3k14

Would it be possible to submit a PR with a test that demonstrates this problem, if it still exists?

asbjornu avatar Mar 08 '22 17:03 asbjornu

Has been resolved with PR https://github.com/GitTools/GitVersion/issues/2336 without the need of specifing IsRelease to true for Hotfix branches.

HHobeck avatar Feb 28 '23 15:02 HHobeck

:tada: This issue has been resolved in version 6.0.0-beta.1 :tada: The release is available on:

Your GitReleaseManager bot :package::rocket:

arturcic avatar Mar 02 '23 21:03 arturcic