Created
October 28, 2014 07:19
-
-
Save hanks/8c7a790530aca11ed333 to your computer and use it in GitHub Desktop.
git pre commit hook to check unsolved conflicts
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 | |
echo | |
count=0 | |
echo "Scanning...Conflict Files List:" | |
for f in `git diff HEAD --name-only --diff-filter=M`; do | |
if [ -f $f ]; then | |
if grep -Fxq "<<<<<<<" $f; then | |
echo " $(tput setaf 1)$f$(tput sgr0)" | |
((count += 1)) | |
fi | |
fi | |
done | |
echo | |
echo "Summary:" | |
if [ $count != 0 ]; then | |
echo " $(tput setaf 1)$count$(tput sgr0) files conflict, need to solve them first!!" | |
exit 1; | |
else | |
echo " $(tput setaf 2)No Conflicts, Start to commit!$(tput sgr0)" | |
echo | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment