Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

git pre commit hook

View pre-commit
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#!/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
Something went wrong with that request. Please try again.