commitizen
commitizen copied to clipboard
cz bump fails if any non semver tag exist
Description
When trying to use cz bump with scm as provider, cz fails on get.version() if there are any tags that does not follow semver. This is probably intentional, but i would expect it to skip the faulty ones and fetch the latest real semver tags and calculate the new version from those. This seems to work fine when you use cz init and it asks "Is this the latest tag?"
Steps to reproduce
- Create a faulty semver tag eg. 0.1.0-1-refs_pull_31_merge
- create a cz config with theese settings:
[tool.commitizen]
name = "cz_conventional_commits"
version_scheme = "semver"
tag_format = "$version"
version_provider = "scm"
- Run cz bump --dry-run
Current behavior
This will yield an exception orginating from packaging/version stating it's an invalid version:
Traceback (most recent call last):
File "/opt/homebrew/bin/cz", line 8, in <module>
sys.exit(main())
^^^^^^
File "/opt/homebrew/Cellar/commitizen/3.12.0/libexec/lib/python3.12/site-packages/commitizen/cli.py", line 565, in main
args.func(conf, arguments)()
File "/opt/homebrew/Cellar/commitizen/3.12.0/libexec/lib/python3.12/site-packages/commitizen/commands/bump.py", line 136, in __call__
current_version = self.scheme(provider.get_version())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/opt/python-packaging/lib/python3.12/site-packages/packaging/version.py", line 200, in __init__
raise InvalidVersion(f"Invalid version: '{version}'")
packaging.version.InvalidVersion: Invalid version: '0.1.0-1-refs_pull_31_merge'
Desired behavior
I would like it to be able to skip the faulty ones and use the latest "ok" semver version as it seems to do when generating the toml file. Or, if a explicit version i set with
cz bump 1.0.1
Use that version and skip the check against tags altogether.
Screenshots
No response
Environment
Commitizen Version: 3.12.0 Python Version: 3.12.0 (main, Oct 5 2023, 15:44:07) [Clang 14.0.3 (clang-1403.0.22.14.1)] Operating System: Darwin