Created
April 5, 2018 09:00
-
-
Save pistatium/3001fb446ffd9728333e3a716d696444 to your computer and use it in GitHub Desktop.
コミットメッセージの先頭に絵文字がないと失敗するgit hook
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/bash | |
msg=`cat "$1"` | |
if [[ "$msg" =~ ^[^:] ]]; then | |
echo >&2 Commit message is not starting emoji. | |
exit 1 | |
fi | |
# emojify 後と比較して変わってなければ不正な絵文字 | |
emojified=`emojify $msg` | |
# なぜか直接比較すると失敗するので md5 | |
s1=$(echo $msg | md5) | |
s2=$(echo $emojified | md5) | |
if [ "$s1" == "$s2" ]; then | |
echo >&2 Invalid emoji: $msg | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
使い方
.git/hooks/commit-msg
にこれを設置