mbarkhau / bumpver

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

Add a HASH part #222

Closed atwam closed 1 year ago

atwam commented 1 year ago

Hi, Having spent now a few months with bumpver for a project, I became frustated by the GITHASH part: Because GITHASH forces a starting . then a hash, it is not possible to have a version that matches both v2023.40.0 and v2023.40.0+1234. The former can be obtained with vYYYY.0W.INC0, the latter with vYYYY.0W.GITHASH. If one combines both with vYYYY.0W[.INC0][GITHASH], then trying to set a version to v2023.40.0 will just omit the last .0, because it's the default value of optional .INC0. The resulting version v2023.40 is not semver compliant, and will break some tools (for example cargo)

I have added the HASH part, to be any hexadecimal hash. This is useful to add a hash-like that may come from any checksum, vsc.

This allows patterns where a hash may be present or ommitted, such as vYYYY.0W.INC0[\+HASH] which can accept v2023.40.0 or v2023.40.1+abc123

mbarkhau commented 1 year ago

I've renamed the part to HEXHASH, primarily to avoid this lint error: A001 variable "hash" is shadowing a python builtin.

mbarkhau commented 1 year ago

As with the GITHASH part, I'm going to leave this undocumented. Ultimately I think this still needs some work to be populated automatically. As far as I can tell, this part can only be populated using --set-version, which defeats a large part of the purpose of bumpver.

atwam commented 1 year ago

Thanks for fixing the checks. I agree that this defeats partly the purpose of bumpver, or rather it makes a partial use of it in my case:

mbarkhau commented 1 year ago

Fixed with 2023.1127