mbarkhau / bumpver

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

Support for pre/post commit hooks #214

Closed malnvenshorn closed 1 year ago

malnvenshorn commented 1 year ago

Closes #178

Implements two new command line parameter --pre-commit-hook, --post-commit-hook and their config counterparts pre_commit_hook, post_commit_hook.

Example output:

$ bumpver update --post-commit-hook changelog.sh
INFO    - fetching tags from remote (to turn off use: -n / --no-fetch)
INFO    - Old Version: 2023.1001-alpha
INFO    - New Version: 2023.1002-alpha
INFO    - git commit --message 'bump version 2023.1001-alpha -> 2023.1002-alpha'
INFO    - Run post-commit hook: changelog.sh
INFO    -   Adding new item in CHANGES.md
INFO    -   Commiting CHANGES.md
INFO    - git tag --annotate 2023.1002-alpha --message '2023.1002-alpha'
$bumpver update --post-commit-hook changelog.sh
INFO    - fetching tags from remote (to turn off use: -n / --no-fetch)
INFO    - Latest version from VCS tag: 2023.1002-alpha 
INFO    - Working dir version        : 2023.1002-alpha
INFO    - Old Version: 2023.1002-alpha
INFO    - New Version: 2023.1003-alpha
INFO    - git commit --message 'bump version 2023.1002-alpha -> 2023.1003-alpha'
INFO    - Run post-commit hook: changelog.sh
ERROR   -   Environment variable FOOBAR is missing
ERROR   - Script exited with an error. Stopping

Checklist

mbarkhau commented 1 year ago

Great work, thank you!