Skip to content

Instantly share code, notes, and snippets.

@starkcoffee
Created May 18, 2012 20:09
Show Gist options
  • Save starkcoffee/2727359 to your computer and use it in GitHub Desktop.
Save starkcoffee/2727359 to your computer and use it in GitHub Desktop.
git precommit hook to warn about ruby puts statements
# thanks to http://codeinthehole.com/writing/tips-for-using-a-git-pre-commit-hook/
FILES_PATTERN='\.rb'
FORBIDDEN='puts '
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 "$FORBIDDEN" references. Please remove them before commiting' && \
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment