Last active
August 29, 2015 14:22
-
-
Save matsuhisa/364306abcda663331315 to your computer and use it in GitHub Desktop.
git commit する前にコンフリクトの残りがないかチェックする ref: http://qiita.com/matsuhisa_h/items/0b9de2ef534807065e54
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 | |
if git rev-parse --verify HEAD >/dev/null 2>&1 | |
then | |
against=HEAD | |
else | |
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 | |
fi | |
# コンフリクトしたファイルを探す | |
# 該当のファイルは、赤文字で表示(Macで確認) | |
for FILE in `git diff-index --name-status $against | grep -E '\.*$' | cut -c3-`; do | |
grep_result=`grep -E '(<<<<<<<|>>>>>>>)' $FILE | grep -v '^$'` | |
if [ -n "${grep_result}" ] | |
then | |
echo $'\e[1;31m'$FILE$'\e[m' ' <- コンフリクトの対応がのこっています' | |
echo $grep_result | |
exit 1 | |
fi | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
もいるのかも