Created
December 13, 2012 21:00
-
-
Save EpeeCheeze/4279807 to your computer and use it in GitHub Desktop.
Commit script to prevent git from committing code with debugging in it
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 | |
for args in $@ | |
do | |
case "$args" in | |
"-f"|"--force") | |
force=true | |
;; | |
esac | |
done | |
debugCode=$(git diff --staged | egrep 'dump|print_r|nocommit|console.log|die|{debug}' -i) | |
if [ ${#debugCode} -gt 0 ]; then | |
echo You have debugging code that you are trying to commit | |
commit=false | |
else | |
commit=true | |
fi | |
if [ $force -o $commit ]; then | |
git commit | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment