mbarkhau / bumpver

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

Epoch versions #208

Closed wenkokke closed 1 year ago

wenkokke commented 1 year ago

BumpVer does not handle epoch versions correctly.

Aside from the fact that there is no EPOCH matcher, the follow configuration produces the wrong PEP440 version:

current_version = "1!2.1.5"
version_pattern = "1!MAJOR.MINOR.PATCH"

This results in the PEP440 version 12.1.5 instead of 1!2.1.5.

mbarkhau commented 1 year ago

Pardon, do you have a link for me, what the semantics of EPOCH are?

wenkokke commented 1 year ago

Pardon, do you have a link for me, what the semantics of EPOCH are?

See version epochs in PEP 440: https://peps.python.org/pep-0440/#version-epochs

For my purposes, the issue is that BumpVer shouldn’t discard the ! in the version when converting to the PEP 440 version.

In terms of EPOCH as a BumpVer pattern, I guess it’d just be another pattern like MAJOR and MINOR. However, it’s unlikely that I’d want to automatically bump into a different epoch, since the semantics of that are changing the versioning scheme, which shouldn’t be a common occurrence.

mbarkhau commented 1 year ago

Hmm, regardless of support for EPOCH, the current behaviour doesn't seem appropriate. I'll investigate further.

If we do add support for EPOCH I think we can add support analogously to MAJOR. I'm in favour of this, regardless of how common/seldom it is used.

mbarkhau commented 1 year ago

I can't quite reproduce the behaviour you're describing, when I use the test command:

$ bumpver test '1!2.1.5-alpha' '1!MAJOR.MINOR.PATCH[-TAG]' --patch
New Version: 1!2.1.6-alpha
PEP440     : 1!2.1.6a0

Is there some more info you can provide?

wenkokke commented 1 year ago

I'd suggest EPOCH as a pattern, so BumpVer is aware of it being a version component, but no corresponding --epoch flag, because bumping the epoch only makes sense if you change your versioning scheme.

Unless --epoch takes a new versioning scheme as an argument, e.g., with version_pattern = "YYYY.BUILD", running --epoch='MAJOR.MINOR.PATCH would bump the epoch and replace the versioning schema. But I suppose that's a lot of work for something that'll be rarely used and difficult to design well.

mbarkhau commented 1 year ago

As I said, regardless of adding it, the characters 1! should be captured as literals and work fine as is. I'm still a bit confused about how the behaviour you're describing, as I cannot replicate it with bumpver test.

wenkokke commented 1 year ago

Try bumpver update --patch with the following:

[project]
version = "1!2.1.5"

[tool.bumpver]
current_version = "v1!2.1.5"
version_pattern = "v1!MAJOR.MINOR.PATCH"

[tool.bumpver.file_patterns]
"pyproject.toml" = [
  'version = "{pep440_version}"',
  'current_version = "{version}"'
]

Which changes version to 12.1.5.

mbarkhau commented 1 year ago

Ok, perfect. Thank's for the repro.

mbarkhau commented 1 year ago

Try 2023.1124, I think this issue should be fixed.