Last active
March 10, 2021 19:26
-
-
Save spersico/2e1bf40813a84d0842b185a23f38daf2 to your computer and use it in GitHub Desktop.
"No debug on commits please" hook
This file contains 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 | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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).