Created
December 1, 2022 15:22
-
-
Save FinchPowers/1f72ca95698e2a77dcd28ed9605aa76f to your computer and use it in GitHub Desktop.
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 | |
# Drop this in a project .git/hooks/prepare-commit-msg | |
COMMIT_MSG_FILE=$1 | |
COMMIT_SOURCE=$2 | |
# SHA1 is not empty if it's a rebase / ammend | |
SHA1=$3 | |
# template | |
# summary | |
# <blank line> | |
# ref: <extracted ticket id> | |
# rest of default commit message | |
if [ -z "$COMMIT_SOURCE" ] && [ -z "$SHA1" ]; then | |
MSG=" | |
ref: $(git branch --show-current | grep -E --only-matching '^LL22-[0-9]+') | |
" | |
fi | |
MSG="$MSG$(cat $COMMIT_MSG_FILE)" | |
printf "$MSG" > $COMMIT_MSG_FILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment