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 ] |
oh pas mal cette petite commande :) je vais voir si je peux faire un truc un peu plus sexy avec :)
merci giuminou
couldn't improve it a lot :(
could make it into a one/two liner if I could return to modified_matching_files
only files were forbidden
is added (+)
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.
I like that :) updated
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
C'est vrai que ça manque une commande simple pour faire ce genre de trucs. En général je me contente de
git diff -Sfoo
.