Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- #
- # Prevents debug traces and sensitive data to be commited.
- #
- # What to search for
- FUNCTIONS='var_dump\(|phpinfo\(|print_r\('
- # Prevent the commit if something is found.
- # default: true
- DIEONFAIL=true
- if git-rev-parse --verify HEAD >/dev/null 2>&1; then
- against=HEAD
- else
- against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
- fi
- # Redirect output to stderr.
- exec 1>&2
- for FILE in $(git diff-index --name-status $against -- | cut -c3-) ; do
- if [ "$(egrep -n --regexp="(${FUNCTIONS})" "${FILE}")" ]
- then
- echo "${FILE} contains debug traces!"
- if [ $DIEONFAIL = true ]
- then
- echo "Changes not committed."
- exit 1;
- else
- echo "You may want to clean these up before push these changes."
- exit 0;
- fi
- fi
- done
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement