mbarkhau / bumpver

BumpVer: Automatic Versioning
https://github.com/mbarkhau/bumpver
MIT License
199 stars 36 forks source link

Incorrect version comparison when updating from vcs tag #174

Closed timobrembeck closed 2 years ago

timobrembeck commented 2 years ago

The version check in _update_cfg_from_vcs() just does a regular string comparison, which does not work when the version numbers are not zero-padded:

https://github.com/mbarkhau/bumpver/blob/328ef5c10a8b1f810b4bf3a28d1e5b4e8fdab3aa/src/bumpver/cli.py#L668

E.g., I use the version pattern YYYY.MM.INC0[-TAG] and have multiple local alpha versions which I don't commit to the vcs, but just use to publish dev versions to test.pypi.org. However, this workflow failed today, because the tools thinks that the version from my git tag 2022.3.2 is newer than my local alpha version 2022.3.10a0.

Because "2022.3.9a0" <= "2022.3.2" is False, the previous build succeeded and "2022.3.10a0" <= "2022.3.2" is True, it does not allow me to bump my version any further than that and sets the version back to 2022.3.3-alpha, which causes pypi to fail because this version already exists.

I would really appreciate any help and would also try to fix this if you point me into the right direction.

mbarkhau commented 2 years ago

Good catch. You can have a look at the function parse_version(version: str) -> typ.Any.

So you might be able to change that line:

- if latest_version_tag <= cfg.current_version: 
+ if version.parse_version(latest_version_tag) <= version.parse_version(cfg.current_version): 
mbarkhau commented 2 years ago

Uploaded to pypi 2022.1116