Skip to content

Instantly share code, notes, and snippets.

@Eunoia
Forked from lsaffie/pre-commit
Last active December 24, 2015 05:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Eunoia/6748443 to your computer and use it in GitHub Desktop.
Save Eunoia/6748443 to your computer and use it in GitHub Desktop.
#!/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