Skip to content

Instantly share code, notes, and snippets.

@EpeeCheeze
Created December 13, 2012 21:00
Show Gist options
  • Save EpeeCheeze/4279807 to your computer and use it in GitHub Desktop.
Save EpeeCheeze/4279807 to your computer and use it in GitHub Desktop.
Commit script to prevent git from committing code with debugging in it
#!/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