Skip to content

Instantly share code, notes, and snippets.

@pistatium
Created April 5, 2018 09:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pistatium/3001fb446ffd9728333e3a716d696444 to your computer and use it in GitHub Desktop.
Save pistatium/3001fb446ffd9728333e3a716d696444 to your computer and use it in GitHub Desktop.
コミットメッセージの先頭に絵文字がないと失敗するgit hook
#!/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
@pistatium
Copy link
Author

使い方

  • emojify をインストール
  • .git/hooks/commit-msg にこれを設置

@pistatium
Copy link
Author

pistatium commented Apr 5, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment