petervanderdoes/gitflow-avh

Help with git flow, commitizen and automatic version increment

krish2487 opened this issue · 2 comments

Hello folks,

I apologize if this is a silly issue to ask, but I need some help with git flow and commitizen - specifically for the release flow.

I use commitizen for standardizing the commit messages presently. I see that commitizen also allows for the autobump of versions and changelog generation based on the commits. I would like to use this in conjunction with git flow.

This is more or less what I have in mind.

git flow init -d

cz init

git flow feature start <feature_name>
__commits using `cz commit`__
git flow feature finish <feature_name>

cz bump --changelog --yes --dry-run

git flow release start (output from the above command)
cz bump --changelog --yes
git flow release finish <release version>

There is a small problem with the above workflow.
The moment I run the cz bump command without the --dry-run option in the release section. It creates the changelog and also creates a tag.
That prevents the git flow release finish command to error and not complete.
Specifically this message

Fatal: Tag already exists and does not point to release branch

I was wondering if anyone else has a solution to the above, rather silly issue.
In short, I am looking for a solution to automatically incrementing the semver of the code, and changelog generation.
I will be very grateful if anyone can help with a workaround or provide with an alternative to the automatic version increment.

Thank you in advance!! :-)

Ok. the closest I have to come to doing this is by the following method.


cz init

git flow feature start <feature_name>
__commits using `cz commit`__
git flow feature finish <feature_name>

cz bump --changelog --yes --dry-run

git flow release start (output from the above command)
cz bump --changelog --yes -pr alpha
git flow release finish <release version>

The

cz bump --changelog --yes -pr alpha

Creates tag with the suffix a0 or whatever to indicate that it is an alpha release, whereas the main release can be versioned without this "alpha" tag. This is one workaround I am able to think of atm. I was wondering if anyone has a more elegant or better solution.

EDIT: This does not work for subsequent features after the first feature.. :-(

Ok.
Solved it..
It was mostly the same workflow, with one minor change.
I asked here on commitizen repo as well
and it turns out, just adding the -n flag will prevent git flwo from creating tags and that is pretty much the solution.

Screen Shot 2021-03-02 at 11 17 05

This is just a sample repo I created to validate the suggestion and the repo commit history looks like the above image..
I am closing this issue now.

Thank you again folks! :-)
It is a very useful tool to work with git!!