c4urself / bump2version

Version-bump your software with a single command
https://pypi.python.org/pypi/bump2version
MIT License
1.05k stars 134 forks source link

Bump2version doesn't fail when tag already exists #224

Open jozenstar opened 3 years ago

jozenstar commented 3 years ago

Hi, I'm using bump2version in my CI process on CircleCI.

I've mentioned that when the tag already exists, bump2version throws an error like

Adding changes in file 'helm/Chart.yaml' to Git
Adding changes in file '.bumpversion.cfg' to Git
Committing to Git with message '"[skip ci]  circleci-bot: bump version 0.54.0 → 0.55.0"'
Tagging 'v0.55.0' with message 'Bump version: 0.54.0 → 0.55.0' in Git and not signing
fatal: tag 'v0.55.0' already exists
Traceback (most recent call last):
  File "/usr/bin/bump2version", line 11, in <module>
    sys.exit(main())
  File "/usr/lib/python3.6/site-packages/bumpversion/cli.py", line 137, in main
    _tag_in_vcs(vcs, context, args)
  File "/usr/lib/python3.6/site-packages/bumpversion/cli.py", line 728, in _tag_in_vcs
    vcs.tag(sign_tags, tag_name, tag_message)
  File "/usr/lib/python3.6/site-packages/bumpversion/vcs.py", line 138, in tag
    subprocess.check_output(command)
  File "/usr/lib/python3.6/subprocess.py", line 356, in check_output
    **kwargs).stdout
  File "/usr/lib/python3.6/subprocess.py", line 438, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['git', 'tag', 'v0.55.0', '--message', 'Bump version: 0.54.0 → 0.55.0']' returned non-zero exit status 128.
CircleCI received exit code 0

So the git tag command exits with exit code 128, but the bump2version process still exits with an exit code 0, so the build is finished 'successfully'.

Bump2version version is bumpversion: v1.0.1 (using Python v3.6.8)

Bump2version config is:


current_version = 0.54.0
commit = True
tag = True
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)
message = "[skip ci]  circleci-bot: bump version {current_version} → {new_version}"

[bumpversion:file:helm/Chart.yaml]```

Can we add some sort of check or exception to catch this error and exit with a non-zero code please?  
florisla commented 3 years ago

Agreed that it should not exit with ERRNO 0.

jozenstar commented 3 years ago

@florisla Thanks for the quick response!

Any thoughts on when this issue could be resolved?

jozenstar commented 2 years ago

@florisla Any updates so far?