c4urself / bump2version

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

Bug: setting sign_tags=False in config file doesn't work #269

Open janfrederik opened 1 year ago

janfrederik commented 1 year ago

How to reproduce

.bumpversion.cfg:

[bumpversion]
current_version = 0.0.1
commit = True
tag = True
sign_tags = False

Running bump2version patch gives the following error:

Tagging 'v0.0.2' with message 'Bump version: 0.0.1 → 0.0.2' in Git and signing
error: gpg failed to sign the data
error: unable to sign the tag
Traceback (most recent call last):
  File "/home/janfr/.pyenv/versions/jkx-3.11.4/bin/bump2version", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/janfr/.pyenv/versions/3.11.4/envs/jkx-3.11.4/lib/python3.11/site-packages/bumpversion/cli.py", line 137, in main
    _tag_in_vcs(vcs, context, args)
  File "/home/janfr/.pyenv/versions/3.11.4/envs/jkx-3.11.4/lib/python3.11/site-packages/bumpversion/cli.py", line 731, in _tag_in_vcs
    vcs.tag(sign_tags, tag_name, tag_message)
  File "/home/janfr/.pyenv/versions/3.11.4/envs/jkx-3.11.4/lib/python3.11/site-packages/bumpversion/vcs.py", line 138, in tag
    subprocess.check_output(command)
  File "/home/janfr/.pyenv/versions/3.11.4/lib/python3.11/subprocess.py", line 466, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/janfr/.pyenv/versions/3.11.4/lib/python3.11/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['git', 'tag', 'v1.0.0-1', '--sign', '--message', 'Bump version: 0.0.0-0 → 1.0.0-1']' returned non-zero exit status 128.

Root cause

The value for tag_name is not converted to a boolean when parsing the config file.
See line 297 in function def _load_configuration() in cli.py:

    for boolvaluename in ("commit", "tag", "dry_run"):
        try:
            defaults[boolvaluename] = config.getboolean(
                "bumpversion", boolvaluename
            )

The tuple should contain "tag_name" as well.