Created
April 25, 2018 03:22
-
-
Save tylerszabo/a664a42cfc5ef698902370b092d7123c to your computer and use it in GitHub Desktop.
Pre-commit hook for catching "FIXME"
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 | |
# | |
# Prevent "FIXME" from appearing in diffs | |
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 | |
# If you want to allow FIXME to appear in diffs | |
allowfixme=$(git config --bool hooks.allowfixme) | |
# Redirect output to stderr. | |
exec 1>&2 | |
if [ "$allowfixme" != "true" ] && | |
test $(git diff --cached --diff-filter=AMCX -z $against | | |
LC_ALL=C grep -i '^+.*fixme' | wc -c) != 0 | |
then | |
cat <<\EOF | |
Error: Commit contains the word "FIXME" | |
Use 'git diff --cached' to locate | |
You can disable this check using: | |
git config hooks.allowfixme true | |
EOF | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment