Last active
September 27, 2022 09:09
-
-
Save florianpasteur/649f735ea786130922dbdd8308e547a2 to your computer and use it in GitHub Desktop.
Post commit hook to auto tag commits based on commit message
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Install command: | |
# curl https://gist.githubusercontent.com/florianpasteur/649f735ea786130922dbdd8308e547a2/raw -o .git/hooks/post-commit && chmod +x .git/hooks/post-commit | |
echo "POST COMMIT HOOK" | |
COMMIT_HASH=HEAD | |
echo "commit hash: $COMMIT_HASH" | |
COMMIT_MESSAGE=$(git log --format=%B -n 1 "$COMMIT_HASH") | |
if echo "$COMMIT_MESSAGE" | grep "@tag:"; | |
then | |
TAG=$(echo "$COMMIT_MESSAGE" | sed -n -e 's/.*@tag://p'); | |
git tag -f "${TAG}" "$COMMIT_HASH" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment