Skip to content

Instantly share code, notes, and snippets.

@ross-nordstrom
Last active March 26, 2016 17:54
Show Gist options
  • Save ross-nordstrom/96d631f57c85b786c1ca to your computer and use it in GitHub Desktop.
Save ross-nordstrom/96d631f57c85b786c1ca to your computer and use it in GitHub Desktop.
Prevent commits with keywords you shouldn't ever have in production code. Just put this file under `<repo>/.git/hooks/pre-commit`
#!/bin/sh
for FILE in `git diff-index --name-only HEAD --` ; do
# Check if the file contains 'debugger'
if cat $FILE | grep -q 'debugger' $FILE; then
echo $FILE ' contains debugger!'
exit 1
fi
# Check if the file contains 'console.log'
if cat $FILE | grep -q 'console.log' $FILE; then
echo $FILE ' contains console.log!'
exit 1
fi
# Check if the file contains 'describe.only'
if cat $FILE | grep -q 'describe.only' $FILE; then
echo $FILE ' contains describe.only!'
exit 1
fi
# Check if the file contains 'it.only'
if cat $FILE | grep -q 'it.only' $FILE; then
echo $FILE ' contains it.only!'
exit 1
fi
done
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment