Skip to content

Instantly share code, notes, and snippets.

@jspiro
Created July 12, 2017 00:09
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 jspiro/2c6091678bb7a33bec65ea32687599a6 to your computer and use it in GitHub Desktop.
Save jspiro/2c6091678bb7a33bec65ea32687599a6 to your computer and use it in GitHub Desktop.
Generate CSV of TODOs by user in Git
#!/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")
@jspiro
Copy link
Author

jspiro commented Jul 12, 2017

E.g. ./todo-count.sh master..develop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment