Advertisement
Guest User

Untitled

a guest
Sep 1st, 2015
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. TEXT_DEFAULT="\\033[0;39m"
  4. TEXT_INFO="\\033[1;32m"
  5. TEXT_ERROR="\\033[1;31m"
  6. TEXT_YELLOW="\\033[1;33m"
  7.  
  8. echo -e "$TEXT_YELLOW""[ >>> PRE-COMMIT START ]""$TEXT_DEFAULT"
  9.  
  10. FILES_PATTERN='(\..+)?$'
  11. FORBIDDEN="console\.(debug|info|log|warn)\([^)]*\)|var_dump\([^)]*\)|print_r\([^)]*\)|<<<<<<<|=======|>>>>>>>"
  12.  
  13. if git diff --cached --name-only | \
  14. grep -E $FILES_PATTERN | \
  15. xargs grep -E --with-filename -n $FORBIDDEN | \
  16. grep -v '//';
  17. then
  18. echo -e "$TEXT_ERROR[ >>> COMMIT REJECTED ]" &&
  19. echo -e "$TEXT_ERROR""If you absolutely need to commit this use git commit --no-verify"
  20. exit 1;
  21. fi
  22.  
  23. echo -e "$TEXT_YELLOW""[ >>> PRE-COMMIT DONE ]""$TEXT_DEFAULT"
  24. exit 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement