Advertisement
Guest User

Untitled

a guest
May 25th, 2015
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #!/bin/sh
  2. #
  3. # Prevents debug traces and sensitive data to be commited.
  4. #
  5.  
  6. # What to search for
  7. FUNCTIONS='var_dump\(|phpinfo\(|print_r\('
  8.  
  9. # Prevent the commit if something is found.
  10. # default: true
  11. DIEONFAIL=true
  12.  
  13. if git-rev-parse --verify HEAD >/dev/null 2>&1; then
  14. against=HEAD
  15. else
  16. against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
  17. fi
  18.  
  19. # Redirect output to stderr.
  20. exec 1>&2
  21.  
  22. for FILE in $(git diff-index --name-status $against -- | cut -c3-) ; do
  23.  
  24. if [ "$(egrep -n --regexp="(${FUNCTIONS})" "${FILE}")" ]
  25. then
  26. echo "${FILE} contains debug traces!"
  27.  
  28. if [ $DIEONFAIL = true ]
  29. then
  30. echo "Changes not committed."
  31. exit 1;
  32. else
  33. echo "You may want to clean these up before push these changes."
  34. exit 0;
  35. fi
  36. fi
  37. done
  38.  
  39. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement