Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- TEXT_DEFAULT="\\033[0;39m"
- TEXT_INFO="\\033[1;32m"
- TEXT_ERROR="\\033[1;31m"
- TEXT_YELLOW="\\033[1;33m"
- echo -e "$TEXT_YELLOW""[ >>> PRE-COMMIT START ]""$TEXT_DEFAULT"
- FILES_PATTERN='(\..+)?$'
- FORBIDDEN="console\.(debug|info|log|warn)\([^)]*\)|var_dump\([^)]*\)|print_r\([^)]*\)|<<<<<<<|=======|>>>>>>>"
- if git diff --cached --name-only | \
- grep -E $FILES_PATTERN | \
- xargs grep -E --with-filename -n $FORBIDDEN | \
- grep -v '//';
- then
- echo -e "$TEXT_ERROR[ >>> COMMIT REJECTED ]" &&
- echo -e "$TEXT_ERROR""If you absolutely need to commit this use git commit --no-verify"
- exit 1;
- fi
- echo -e "$TEXT_YELLOW""[ >>> PRE-COMMIT DONE ]""$TEXT_DEFAULT"
- exit 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement