bump2version icon indicating copy to clipboard operation
bump2version copied to clipboard

Feature request: tag HEAD, then commit

Open johnflavin opened this issue 6 years ago • 5 comments

I know it is possible to use this tool to perform this sequence of actions when bumping the version:

  • create commit for bumped version
  • tag new commit with new version

Is it possible to perform this sequence of actions?

  • tag HEAD commit with current version
  • create commit for bumped version

johnflavin avatar Oct 30 '19 11:10 johnflavin

I think this is currently not possible.

Of course you could call git tag first, and then bump2version to create a bump commit.

florisla avatar Oct 30 '19 15:10 florisla

I guess it's debatable whether or not we should support this (open for a discussion) -- I think we need to consider the Unix philosophy "Make each program do one thing well."

c4urself avatar Oct 30 '19 15:10 c4urself

Maybe you could use --no-commit --tag and maybe set the new version to match the current version and then call it with --commit --no-tag.

It sounds to me like you'd have a workflow where you want to have the next version in git. It might be cleaner to commit the final version number and then have a commit to bump to a -pre version. So

  • master is 0.1.2-pre
  • Release 0.1.2 (bump + commit + tag)
  • Bump master to 0.1.3-pre (bump + commit, no tag)

Would that work for you? I also think the tool can already support this today.

ekohl avatar Oct 30 '19 15:10 ekohl

Of course you could call git tag first, and then bump2version to create a bump commit.

This is what I'm doing currently. It does the workflow I want to do, but it has the disadvantages of needing to run two commands, and of having to know the current version to pass to git tag. (I suppose I could figure out some bash one-liner to parse it from one of my files, but that makes an awkward workflow even more awkward.)

For a little more context of why I would like to do this: I have jenkins set to build and deploy artifacts on each commit to master. But I only ever commit to master in a PR from a develop or rc branch. Once I merge that PR, I want to run something like this:

git checkout develop
git merge master
bump2version <some command to tag HEAD with current version, since the artifact with that version has already been built from that commit, then bump to next version and commit to develop>

At the end develop will have a single commit beyond master that bumps to the next version, ready to start more feature branches. But that version won't ever be deployed until the next merge to master.

Maybe you could use --no-commit --tag and maybe set the new version to match the current version and then call it with --commit --no-tag.

This could work. I'll have to give it a try.

EDIT Though now that I think about it, that might not be any different from my current workflow. I don't think I see the difference between running

bump2version --no-commit --tag <current version>

and running

git tag <current version>

johnflavin avatar Oct 31 '19 02:10 johnflavin

I think the same conclusion applies as in https://github.com/c4urself/bump2version/issues/100#issuecomment-573570860: an advanced worklow like this is best automated outside of bump2version.

florisla avatar Jan 14 '20 08:01 florisla