-
-
Save ranbena/5163272 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/sh | |
# pre-commit git hook to make sure developers don't accidentally commit code they didn't mean to commit :) | |
REMOVEME_STRING="REMOVEME" | |
DEBUGGER_STRING="debugger" | |
ALLOW_COMMITTING_REMOVEME=`git config hooks.allowcommittingremoveme` | |
# redirect stdout to stderr | |
exec 1>&2 | |
if [ "$ALLOW_COMMITTING_REMOVEME" != "true" ] && | |
([ "$(git diff --cached | egrep '^\+[^\+]+' | grep $REMOVEME_STRING)" != "" ] || | |
[ "$(git diff --cached | egrep '^\+[^\+]+' | grep $DEBUGGER_STRING)" != "" ]) | |
then | |
echo "Error: Uh oh, you forgot a $REMOVEME_STRING or $DEBUGGER_STRING in your code." | |
echo | |
echo "If you want to disable this check use:" | |
echo " git config hooks.allowcommittingremoveme true" | |
echo "When you're done, set it back using:" | |
echo " git config --unset hooks.allowcommittingremoveme" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment