Skip to content

Instantly share code, notes, and snippets.

@edumucelli
Created May 20, 2022 13:20
Show Gist options
  • Save edumucelli/8d25806d845e8d42888f056fad119033 to your computer and use it in GitHub Desktop.
Save edumucelli/8d25806d845e8d42888f056fad119033 to your computer and use it in GitHub Desktop.
Count TODO on your Git repositories
#!/bin/bash
declare -a Repos=(
"https://github.com/canonical/go-dqlite.git" "https://github.com/canonical/ubuntu-image"
)
# That is not a fault-proof TODO counting, just something that give a good enough counting.
# There might be multiple edge cases not considered here. Leave a comment for improvements.
for val in ${Repos[@]}; do
git clone $val counting > /dev/null 2>&1
AllTodos=`(cd counting && git grep -E "TODO|TODO:|TODO\(" | wc -l)`
ContextTodos=`(cd counting && git grep -E "context.TODO" | wc -l)`
# On Go repositories, there is sometimes context.TODO that we need to discard.
paste <(echo $val) <(echo $((AllTodos-ContextTodos)) )
rm -rf counting
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment