mirror of
https://github.com/bndr/pipreqs.git
synced 2025-06-06 19:45:22 +00:00
Add a git hook for automatic tagging
- When the version field of `pyproject.toml` changes, after the changes have been committed, a tag is created with `git tag` that refers to the new version. - It's necessary to configure the `git-hooks' directory `git config core.hooksPath .git-hooks`.
This commit is contained in:
parent
4826afdac0
commit
ef7583a8dd
10
.git-hooks/post-commit
Executable file
10
.git-hooks/post-commit
Executable file
@ -0,0 +1,10 @@
|
||||
#! /bin/bash
|
||||
version=`git diff HEAD^..HEAD -- "$(git rev-parse --show-toplevel)"/pyproject.toml | grep -m 1 '^\+.*version' | sed -s 's/[^A-Z0-9\.\-]//g'`
|
||||
|
||||
if [[ ! $version =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)(\-[A-Z]+\.[0-9]+)?$ ]]; then
|
||||
echo -e "Skip tag: invalid version '$version'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
git tag -a "v$version" -m "`git log -1 --format=%s`"
|
||||
echo "Created a new tag, $version"
|
Loading…
x
Reference in New Issue
Block a user