Skip to content

Instantly share code, notes, and snippets.

@meain

meain/pre-commit

Last active Nov 14, 2019
Embed
What would you like to do?
Check for curse words ( used as git pre-commit hook )
# to use this use
# mv pre-commit .git/hooks/pre-commit
# chmod +x .git/hooks/pre-commit
function check_sanity(){
git diff | grep -i 'fuck\|shit\|crap\|dammit\|bitch\|asshole\|shithead'|wc -m
}
function print_insanity(){
git diff | grep -i 'fuck\|shit\|crap\|dammit\|bitch\|asshole\|shithead'
}
if [ $(check_sanity) -gt 0 ]
then
echo "Curse word found!"
echo ""
echo "$(print_insanity)"
exit 1
fi
@crufter

This comment has been minimized.

Copy link

@crufter crufter commented Nov 14, 2019

@meain Very cool!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment