Created
November 8, 2011 21:05
-
-
Save midu/1349223 to your computer and use it in GitHub Desktop.
pre-commit git hook to prevent console.log in javascript files
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
FILES_PATTERN='\.(js|coffee)(\..+)?$' | |
FORBIDDEN='console.log' | |
git diff --cached --name-only | grep -E $FILES_PATTERN | GREP_COLOR='4;5;37;41' xargs grep --color --with-filename -n $FORBIDDEN && echo 'COMMIT REJECTED Found "console.log" references in your javascript. Please remove them before commiting'; | |
# my zsh does annoying things with ! | |
[ $? -ne 0 ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
pourquoi pas un truc genre
PAGER= git diff --cached --name-only | grep '\.\(ext1\|ext2\)$' | xargs grep foo && echo failing && exit 1
Le
git diff -Sfoo
je m'en sert en local car c'est rapide à taper pour vérifier que je commit pas des messages de debug.