Skip to content

Instantly share code, notes, and snippets.

@neur0manc
Created October 16, 2016 20:18
Show Gist options
  • Save neur0manc/cce44e57638d34dd7afcde6adc1f72d8 to your computer and use it in GitHub Desktop.
Save neur0manc/cce44e57638d34dd7afcde6adc1f72d8 to your computer and use it in GitHub Desktop.
Git-Hook to prevent committing code that still contains TODOs
#!/bin/bash
#
# Link this to .git/hooks/pre-commit
# and make sure this script is executable
# (I use `bash` instead of `sh` so I can color the error message)
result=$(grep -REin "// TODO|//TODO" * --exclude pchook.sh)
rc=$?
if [ $rc -eq 0 ]; then
echo -e "\e[31mDon't commit TODOs\e[0m"
echo "$result"
exit 1
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment