Last active
March 17, 2019 23:12
-
-
Save canalesb93/c7977dbe89433b1e841ed525a30fe25b to your computer and use it in GitHub Desktop.
Output a list of all existing TODOs in the codebase
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
echo_red(){ | |
printf "\e[1;31m$1\e[0m" | |
} | |
echo_green(){ | |
printf "\e[1;32m$1\e[0m\n" | |
} | |
echo_yellow(){ | |
printf "\e[1;33m$1\e[0m\n" | |
} | |
echo_blue(){ | |
printf "\e[1;34m$1\e[0m\n" | |
} | |
grep_count() { | |
COUNT=$(git grep "// $1" | wc -l) | |
if [[ COUNT -gt 0 ]]; then | |
TEXT=${1//\//} | |
$2 " * ${COUNT// /} ${TEXT// /}s unresolved" | |
return 1 | |
fi | |
return 0 | |
} | |
grep_count "TODO" echo_blue | |
TODO=$? | |
grep_count "FIXME" echo_yellow | |
FIXME=$? | |
grep_count "OPTIMIZE" echo_green | |
OPTIMIZE=$? | |
grep_count "STOPSHIP" echo_red | |
STOPSHIP=$? | |
if [[ TODO -ne 0 ]] || [[ FIXME -ne 0 ]] || [[ OPTIMIZE -ne 0 ]] || [[ STOPSHIP -ne 0 ]]; then | |
exit 1 | |
fi | |
exit 0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment