Skip to content

Instantly share code, notes, and snippets.

@kristm
Last active December 14, 2015 08:09
Show Gist options
  • Save kristm/5055505 to your computer and use it in GitHub Desktop.
Save kristm/5055505 to your computer and use it in GitHub Desktop.
Print git log in harvest app ready format
#!/bin/bash
if [ $# -lt 3 ]; then
echo -e "hhhh v0.2\nUsage: hhhh <author> <from date> <to date>"
exit
fi
pretty="--pretty=%C(blue)%ad%Creset %C(yellow)%h%C(green)%d%Creset %C(blue)%s %C(magenta) [%an]%Creset"
fl=`git log "$pretty" --author "$1" --since "$2" --until "$3"|awk ' ORS="\n" { $4=$5=$6=$7=""; print $0}'`
echo "$fl"|awk 'FS=" " { gsub(/(\[[A-Za-z0-9&#\ ]+\] ?|Merge.*)/,"");\
if (a != $1){ print sep$1sep$2 } else { print $2 } }\
{ a=$1; sep="\n==========\n" }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment