Skip to content

Instantly share code, notes, and snippets.

@burtyish
Last active April 17, 2018 10:48
Show Gist options
  • Save burtyish/0428aac0d62a7980d84d33f6909ea176 to your computer and use it in GitHub Desktop.
Save burtyish/0428aac0d62a7980d84d33f6909ea176 to your computer and use it in GitHub Desktop.
pre-push git hook, prevents pushing if any new `TODO`s were added
#!/bin/sh
# Place this file in the `.git/hooks` directory
HITS=0
for FILE in `git diff origin/HEAD --name-only`; do
grep 'TODO' $FILE 2>&1 >/dev/null
if [ $? -eq 0 ]; then
echo 'New TODO found in file: ' $FILE
((HITS++))
exit 1
fi
done
exit $HITS
# Add these lines to a new/existing pre-push file in your `.git/hooks` directory
set -e
.git/hooks/no-todos.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment