Skip to content

Instantly share code, notes, and snippets.

@mahdi-malv
Forked from shahin-you/pre-commit
Last active March 6, 2024 16:25
Show Gist options
  • Save mahdi-malv/b36c76f2f9e93545b8e977903bbae449 to your computer and use it in GitHub Desktop.
Save mahdi-malv/b36c76f2f9e93545b8e977903bbae449 to your computer and use it in GitHub Desktop.
Block the commit if there was unmentioned TODO
#!/bin/sh
# Check for "TODO" in staged files
TODO_FOUND=$(git diff --cached --name-only --diff-filter=AM | grep -E '\.(kt|java|xml|kts|properties)$' | xargs -r grep -l 'TODO')
if [ ! -z "$TODO_FOUND" ]; then
echo "🔴 These TODOs are not refering to any task"
echo "$TODO_FOUND"
echo "Consider addressing the TODOs or creating tickets for them before committing."
# Uncomment the next line to block the commit until TODOs are addressed
exit 1
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment