Created
October 18, 2012 17:41
-
-
Save joxxoxo/3913639 to your computer and use it in GitHub Desktop.
git pre commit 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 | |
## START PRECOMMIT HOOK | |
# git commit .... <-- run with check | |
# NOCHECK=1 git commit ... <-- run without check | |
if [ ! "${NOCHECK}" ]; then | |
files_modified=`git status --porcelain | egrep "^(A |M |R ).*" | awk ' { if ($3 == "->") print $4; else print $2 } '` | |
for f in $files_modified; do | |
echo "Checking ${f}..." | |
if grep --color -n "console.log" $f; then | |
echo "File ${f} failed - found 'console.log'" | |
exit 1 | |
fi | |
if grep --color -n "binding.pry" $f; then | |
echo "File ${f} failed - found 'binding.pry'" | |
exit 1 | |
fi | |
done | |
fi | |
exit | |
## END PRECOMMIT HOOK |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment