Generate timesheet CSVs from git log
Copy paste the following to your ~/.bash_aliases:
function csvgit {
since="9am";
author="ReactiveRaven";
directory="~/Code";
pushd $directory > /dev/null;
find . -maxdepth 2 -name ".git" |
tr "/" "\n" | grep -v "^\.$" | grep -v "^\.git$" |
while read line;
do
pushd "$line" > /dev/null;
git log --all --since="${1:-$since}" --pretty=format:'%ai,%s' --author="${2:-$author}" | sed -E "s/[0-9]{4}-[0-9]{2}-[0-9]{2} //;s/ \+0000//;s/, #/,#/g;"
popd > /dev/null;
done | sort;
popd > /dev/null;
}
and reload your aliases source ~/.bash_aliases
.
Usage:
csvgit "9am last thursday" "LaughingMan"
# all commits since last thursday for LaughingMan
csvgit
# all commits since 9AM for 'me'
Don't forget to update the author=
and since=
to something more useful for you to save typing it out longhand each time, and directory=
to point to where you keep your git projects.
To include the name of the project folder in the commit message, tack this onto the end of the sed
command:
s/,/,$line:/;
Written by David Godfrey
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Csv
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#