GitVersion
GitVersion copied to clipboard
[Fix/Feature] Set Hotfix as release branch by default
Description
By the definition in the documentation it seems that the Hotfix branches should by default have is-release-branch set to true. Discussion can be followed at https://github.com/GitTools/GitVersion/issues/2336.
This change not only modifies how version in Hotfix branch name is treated but as well how merge messages with such branches are handled.
Related Issue
https://github.com/GitTools/GitVersion/issues/2336
Motivation and Context
Version in Hotfix branch names should be taken into consideration when resolving base version by default. This change enables this behavior with default configuration.
How Has This Been Tested?
The branch was build locally and tested manually.
- The default configuration for Hotfix branch has:
is-release-branch: true - The version in branch name is taken into consideration when resolving version on hotfix branch
Additionally there were added a few tests and current test scenarios were adjusted to the change.
Checklist:
- [x] My code follows the code style of this project.
- [x] My change requires a change to the documentation.
- [x] I have updated the documentation accordingly.
- [x] I have added tests to cover my changes.
- [x] All new and existing tests passed.
Yes, my first thought after running the tests were the same. It seems that with previous change it was probably intended mainly for hotfix branch names to not be taken into consideration, as there were a few test case scenarios which expected such behavior.
I don't really know what to think of it as well. On the one hand I would expect for Hotfixes to behave like release branches in some cases by default. But in the end it may be better to just provide appropriate documentation to previous change.
I think we'll target this for version 6, since it introduces breaking changes.
main is now primed for v6. Can you please rebase and solve conflicts so we can merge this, @dramdrung?
I have taken a look into the source code and see that we have two IVersionStrategy implementations in the current version 5.10.3 of GitVersion which are using the IsReleaseBranch property to determine the version. It is on the one hand the VersionInBranchNameVersionStrategy and on the other hand the MergeMessageVersionStrategy class. So far so good.
I'm just wondering why we are not separating this two aspects and make it configurable. For instance we can introduce a new property with the name VersionInBranchNamePattern="{Major}.{Minor}.{Patch}^" or VersionInBranchNamePattern="{Major}.{Minor}^" to specify explicit how the version can be determined.
This has the following advantages:
- If some one want's to configure the pattern how the version is encoded in the branch name then he can do it (see [Bug] Wrong version from the release branche #2925)
- The aspect getting the version from the branch name and the aspect getting the version from other release branches are separated and can be configured.
I'm just wondering why we are not separating this two aspects and make it configurable. For instance we can introduce a new property with the name VersionInBranchNamePattern="{Major}.{Minor}.{Patch}^" or VersionInBranchNamePattern="{Major}.{Minor}^" to specify explicit how the version can be determined.
Sure, that's even something we could introduce in v5 since it's a new configuration property.
Hi @dramdrung. Please rebase your PR with the main branch and give me feedback when you are done.
Has been resolved with PR https://github.com/GitTools/GitVersion/issues/2336 without the need of specifing IsRelease to true for Hotfix branches.