Created
October 9, 2019 03:26
-
-
Save kujiy/00c42381a29cf67f065ed079b86ebe66 to your computer and use it in GitHub Desktop.
Add the branch name to commit message
This file contains 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/sh | |
#ブランチ名を取得 | |
Branch="$(git rev-parse --abbrev-ref HEAD)" | |
#コミットメッセージの最初にブランチ名を追加 | |
#echo "Hook is working..." | |
#echo "コミットメッセージにbranch名を強制付与しています..." | |
MSG=$(cat .git/COMMIT_EDITMSG) | |
PAT="^(squash|fixup)" | |
if echo $MSG | grep -E "$PAT" > /dev/null | |
then | |
# echo "squashから始まるコミットメッセージには強制付与をしません。" | |
echo | |
else | |
mv $1 $1.tmpbycommit-msg | |
echo "[$Branch] $(cat $1.tmpbycommit-msg)" > $1 | |
fi |
Author
kujiy
commented
Oct 9, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment