Last active
July 12, 2024 19:24
-
-
Save spersico/2e1bf40813a84d0842b185a23f38daf2 to your computer and use it in GitHub Desktop.
"No debug on commits" 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 | |
if git rev-parse --verify HEAD >/dev/null 2>&1 | |
then | |
against=HEAD | |
else | |
# Initial commit: diff against an empty tree object | |
against=<PUT_THE_FIRST_COMMIT_HASH_HERE> | |
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 (pretty 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).