-
-
Save RhetTbull/27e343575596ec20ff07d5f0bda3d2b7 to your computer and use it in GitHub Desktop.
pre-commit hook (add to .git/hooks/pre-commit) to refuse to commit debugger strings
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 | |
# Refuse to commit files with the string ZZZ present | |
# I frequently use ZZZ to mark a spot where I'm working on an issue so I can come back to it | |
# | |
NOCOMMIT="ZZZ" | |
files=$(git diff-index --name-status --cached HEAD | grep -v ^D | cut -c3-) | |
if [ "$files" != "" ] | |
then | |
for f in $files | |
do | |
if [[ "$f" =~ [.](py|md|applescript|json)$ ]] | |
then | |
if [ "$(grep $NOCOMMIT $f)" != '' ] | |
then | |
echo "NOCOMMIT message present in file $f, aborting!" | |
echo "$(grep -n -C 3 $NOCOMMIT $f)" | |
exit 1 | |
fi | |
fi | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment