Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cz bump fails if any non semver tag exist #916

Closed
gotpist1 opened this issue Nov 20, 2023 · 1 comment
Closed

cz bump fails if any non semver tag exist #916

gotpist1 opened this issue Nov 20, 2023 · 1 comment

Comments

@gotpist1
Copy link

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

  1. Create a faulty semver tag eg. 0.1.0-1-refs_pull_31_merge
  2. create a cz config with theese settings:
[tool.commitizen]
name = "cz_conventional_commits"
version_scheme = "semver"
tag_format = "$version"
version_provider = "scm"
  1. 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

@Lee-W
Copy link
Member

Lee-W commented May 20, 2024

I just tested in the latest version (3.26.0) without encountering the issue (but there would still be warnings). I'm going to close this one. But please feel free to reopen it if the issue still persists. Thanks!

@Lee-W Lee-W closed this as completed May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants