Skip to content

Instantly share code, notes, and snippets.

@spersico
Last active March 10, 2021 19:26
Show Gist options
  • Save spersico/2e1bf40813a84d0842b185a23f38daf2 to your computer and use it in GitHub Desktop.
Save spersico/2e1bf40813a84d0842b185a23f38daf2 to your computer and use it in GitHub Desktop.
"No debug on commits please" hook
#!/bin/sh
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
# The special marker tag to mark things which we still need to change
marker="debugger"
# Redirect output to stderr.
exec 1>&2
if test $(git diff --cached -z $against | grep $marker | wc -c) != 0
then
cat <<\EOF
Error: YOU LEFT A DEBUGGER ON YOUR CODE. REMOVE IT OR I WONT LET YOU COMMIT (PLEASE).
EOF
exit 1
fi
@spersico
Copy link
Author

spersico commented Aug 24, 2019

And we can put this file in a .hooks folder in the project, and in the package.json we can set "postinstall": "git config core.hooksPath .hooks" so that everyone must follow this rule.

Or just use husky and add it (untested).

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