Skip to content

Instantly share code, notes, and snippets.

@keithhackbarth
Last active March 22, 2024 22:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keithhackbarth/e6cd70dafdd2ead1b6a91c5a623d6ab8 to your computer and use it in GitHub Desktop.
Save keithhackbarth/e6cd70dafdd2ead1b6a91c5a623d6ab8 to your computer and use it in GitHub Desktop.
Check Todos
#!/bin/bash
# Step 1: Store the modified output in a variable
todos=$(git grep -l TODO ./src | grep -v 'graphqlTypes' | xargs -n1 git blame -f -w | grep TODO | sed 's/\([0-9]\{2,\}\)) */\1) /')
# Step 2: Count the number of lines in the modified output
todo_count=$(echo "$todos" | grep -v '^$' | wc -l | sed 's/^[[:space:]]*//') # Remove leading spaces
# Step 3: Print the count in yellow text
if [ "$todo_count" -gt 0 ]; then
echo -e "\033[1;33mWARNING: $todo_count TODO$([ "$todo_count" -gt 1 ] && echo 's') remaining\033[0m"
echo "$todos"
echo ""
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment