Last active
May 9, 2019 09:46
-
-
Save TeTiRoss/54cc264ead24484b2afc75ddcee04ed2 to your computer and use it in GitHub Desktop.
Rails git pre commit hook
This file contains hidden or 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/sh | |
FILES='(js|css|rb)' | |
FORBIDDEN='(<<<<<<<|=======|>>>>>>>|binding.pry|throw|debugger|console.log|\!important)' | |
GREP_COLOR='4;5;37;41' | |
if [[ $(git diff --cached --name-only | grep -E $FILES) ]]; then | |
git diff --cached --name-only | grep -E $FILES | \ | |
xargs grep --color --with-filename -n -E $FORBIDDEN && \ | |
echo "Looks like you are trying to commit something you shouldn't. Please fix your diff, or run 'git commit --no-verify' to skip this check, if you must." && \ | |
exit 1 | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment