Skip to content

Instantly share code, notes, and snippets.

@l-portet
Forked from guilherme/gist:9604324
Last active November 8, 2018 15:28
Show Gist options
  • Save l-portet/28882743b683618e599609c9193b29aa to your computer and use it in GitHub Desktop.
Save l-portet/28882743b683618e599609c9193b29aa to your computer and use it in GitHub Desktop.
Git pre-commit hook that detects if the developer forget to remove all the javascript debugger before commit.
#!/bin/sh
# Redirect output to stderr.
exec 1>&2
# enable user input
exec < /dev/tty
debugregexp='debugger'
# CHECK
if test $(git diff --cached | grep $debugregexp | wc -l) != 0
then
exec git diff --cached | grep -ne $debugregexp
read -p "There are some occurrences of 'debugger' at your modification. Are you sure want to continue? (y/n)" yn
echo $yn | grep ^[Yy]$
if [ $? -eq 0 ]
then
exit 0; #THE USER WANTS TO CONTINUE
else
exit 1; # THE USER DONT WANT TO CONTINUE SO ROLLBACK
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment