Created
November 14, 2011 19:00
-
-
Save EpeeCheeze/1364784 to your computer and use it in GitHub Desktop.
Bash script to prevent committing debug code in Git
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