Last active
July 6, 2016 20:02
-
-
Save grok/ff093f7cbccb604c20621246c922eb5e to your computer and use it in GitHub Desktop.
git pre-commit hook for checking for debug code you don't want committed. Basically add a comment that says // @debug or @debug or @debug -- and this will not let you commit that line.
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/sh | |
disallowed="@debug" | |
RED='\033[0;31m' | |
YELLOW='\033[1;33m' | |
NC='\033[0m' # No Color | |
git diff --cached --name-status | while read x file; do | |
if [ "$x" == 'D' ]; then continue; fi | |
for word in $disallowed | |
do | |
if grep -Ei $word $file > /dev/null; then | |
echo "BRO! You left ${RED}DEBUG CODE${NC} in your shit. I'm not letting you commit this. Go clean your room: Found references to debug code in file: ${YELLOW}${file}${NC}\n" | |
exit 1 | |
fi | |
done | |
done || exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment