Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #!/bin/sh
  2. # this hook is in SCM so that it can be shared
  3. # to install it, create a symbolic link in the projects .git/hooks folder
  4. #
  5. # i.e. - from the .git/hooks directory, run
  6. # $ ln -s ../../git-hooks/pre-commit.sh pre-commit
  7. #
  8. # to skip the tests, run with the --no-verify argument
  9. # i.e. - $ 'git commit --no-verify'
  10. FILES='(js|css|rb)'
  11. FORBIDDEN='(binding.pry|console.log|\!important|focus\: true)'
  12. GREP_COLOR='4;5;37;41'
  13.  
  14. if [[ $(git diff --cached --name-only | grep -E $FILES) ]]; then
  15. git diff --cached --name-only | grep -E $FILES | \
  16. xargs grep --color --with-filename -n -E $FORBIDDEN && \
  17. echo "Looks like you are trying to commit something you shouldn't. Please fix your diff, or run 'git commit --no-verify' to skip this check, if you must." && \
  18. exit 1
  19. fi
  20.  
  21. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement