问题
I think I am using the "https://github.com/nvie/gitflow", if that is the one which comes within the Smartgit GUI program.
Every time I to commit something, I update the 'build' number. Example: 2.6.0-77 to 2.6.0-78
This is already implemented to hook the pre-commit and increment the build number, but how to create a hook to hook the gitflow hotfix finish and to increment the hotfix version number? Example: 2.6.0-70 to 2.6.1-70
The code to increment the hotfix version is already done. We just need to run:
githooks/updateVersion.sh patch
Then, we got 2.6.0-70 to 2.6.1-70 over the project. This code is implemented here: https://github.com/evandrocoan/.versioning
There, the pre-commit, post-commit hooks are implemented.
If it cannot to be done, we could to do it on the pre-commit hook? We just need to know when we are committing something ordinary, and when we are committing the gitflow finish hotfix.
回答1:
I can also think about to read the commit message and then determine whether it is a normal commit (./githooks/updateVersion.sh build), or an hotfix (./githooks/updateVersion.sh patch).
I mean, to create a pattern over the project and only at the finish hotfix to use that keyword, which will be got by the pre-commit hook. Something like, always to start a finish hotfix within the words 'Finish hotfix'.
Then also, the same could be applied to minor and major releases, then we could always automatically update the software version.
Obs
This assumes a version were "Major.Minor.Patch-Build", where build is the commit counter which is incremented every develop branch commit.
But this is a wrong branching model, we cannot commit things into the develop branch, we must create feature branches. We always increment the Patch number, every hotfix Release. But do not touch the build number. Then we should increment the the build number, every Feature Finish. And increment the Major or Minor number every Release Start, depending it was major features or minor features release.
But this causes a problem. If we create Features A, B and C. Finish the feature A, then increment the build number but, when we finish the Feature B or C, if will give a conflict because their build numbers are out-of-date.
The solution is to integrate the development before every feature finish, them we can get the right build number while integrating, then we avoid conflicts.
来源:https://stackoverflow.com/questions/37084160/how-to-pre-hook-the-gitflow-hotfix-finish