Skip to content

Instantly share code, notes, and snippets.

@fmoor
Created September 24, 2024 23:58
Show Gist options
  • Save fmoor/58240f600a95adb6c3708fcd4ff5a263 to your computer and use it in GitHub Desktop.
Save fmoor/58240f600a95adb6c3708fcd4ff5a263 to your computer and use it in GitHub Desktop.
Prevent commiting TODO comments with a git hook
#!/usr/bin/env bash
# https://stackoverflow.com/a/7292992
# https://git-scm.com/docs/git-sh-setup
. "$(git --exec-path)/git-sh-setup"
if git diff-index -p -M --cached HEAD -- \
| grep ^+ \
| grep --ignore-case TODO
then
die "Blocking commit because string \`todo\` detected in patch."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment