Created
July 12, 2017 00:09
-
-
Save jspiro/2c6091678bb7a33bec65ea32687599a6 to your computer and use it in GitHub Desktop.
Generate CSV of TODOs by user in Git
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
#!/usr/bin/env bash | |
revs=$(git rev-list "$1" | wc -l | awk '{ printf "%d\n", $0 }') | |
revnum=0 | |
ignores="--ignore todo-count.sh --ignore out.csv --ignore thirdparty --ignore govendor" | |
people=( "sarietta" "cjrd" "jspiro" "avi" ) | |
echo "date,sha,file count,todo count,$(printf "%s," "${people[@]}")" > out.csv | |
while read -r rev; do | |
let "revnum++" | |
echo "checking out $rev ($revnum/$revs)" | |
if ! git checkout -f "$rev"&>lasterror.txt; then | |
echo ERRRRRRRRRRRRRRRRRRRRRRROR | |
cat lasterror.txt | |
exit 1 | |
fi | |
date=$(git show -s --format=%ci) | |
files=$(find . -type f | wc -l) | |
totals=$(ag --count $ignores todo `pwd` | cut -d : -f 2 | paste -sd+ - | bc) | |
for person in "${people[@]}"; do | |
count=$(ag --count $ignores "todo.*\b$person\b" `pwd` | cut -d : -f 2 | paste -sd+ - | bc) | |
if [ "$count" == "" ]; then count=0; fi | |
totals+=",$count" | |
done | |
echo "$date,$rev,$files,$totals" >> out.csv | |
done < <(git rev-list --reverse "$1") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
E.g.
./todo-count.sh master..develop