Advertisement
vedranvinko

Keeping Pry Breakpoints out of Git

Jun 30th, 2015
378
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.86 KB | None | 0 0
  1. # Code by ALEX BEVILACQUA
  2.  
  3. # Git pre-commit hook to check all staged Ruby (*.rb/haml/coffee) files
  4. # for Pry binding references
  5. #
  6. # Installation
  7. #
  8. #   ln -s /path/to/pre-commit.sh /path/to/project/.git/hooks/pre-commit
  9. #
  10. # Based on
  11. #
  12. #   http://codeinthehole.com/writing/tips-for-using-a-git-pre-commit-hook/
  13. #   http://mark-story.com/posts/view/using-git-commit-hooks-to-prevent-stupid-mistakes
  14. #   https://gist.github.com/3266940
  15. #
  16. FILES_PATTERN='\.(rb|haml|coffee)(\..+)?$'
  17. FORBIDDEN='binding.pry'
  18.  
  19. git diff --cached --name-only | \
  20.     grep -E $FILES_PATTERN | \
  21.     GREP_COLOR='4;5;37;41' xargs grep --color --with-filename -n $FORBIDDEN && \
  22.     echo 'COMMIT REJECTED' && \
  23.     exit 1
  24.  
  25. exit 0
  26.  
  27. # This file just needs to be saved to /path/to/source/.git/hooks/pre-commit and made executable.
  28. # chmod +x /path/to/source/.git/hooks/pre-commit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement