-
-
Save Eunoia/6748443 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# echo $ | |
#This is good j | |
git diff --cached | grep -i "^\+[^#]*debugger" && | |
# git diff --cached --name-only --diff-filter=ACM | |
exit 1 | |
# Pre commit hook that prevents FORBIDDEN code from being commited. | |
# Add unwanted code to the FORBIDDEN array as necessary | |
FILES_PATTERN='\.(rb|js|coffee|html|haml)(\..+)?$' | |
FORBIDDEN=( debugger ruby-debug binding.pry ) | |
for i in "${FORBIDDEN[@]}" | |
do | |
git diff --cached --name-only xargs grep --color --with-filename -n -i "^\+[^#]*$i" && exit 1 | |
# git diff --cached --name-only | \ | |
# grep -E $FILES_PATTERN | \ | |
# GREP_COLOR='4;5;37;41' xargs grep --color --with-filename -n '^\+[^#]*$i' && \ | |
# echo 'COMMIT REJECTED Found' $i 'references. Please remove them before commiting' && exit 1 | |
done | |
# exit 0 | |
# #!/bin/sh | |
# if git-rev-parse --verify HEAD >/dev/null 2>&1; then | |
# against=HEAD | |
# else | |
# against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 | |
# fi | |
# for FILE in `git diff-index --name-status $against -- | cut -c3-` ; do | |
# # Check if the file contains 'debugger' | |
# if [ "grep 'debugger' $FILE" ] | |
# then | |
# echo $FILE '- contains debugger!' | |
# exit 1 | |
# fi | |
# done | |
# exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment