Last active
October 19, 2015 20:43
-
-
Save mc706/1bf3cd89cfb2ffe92b4e to your computer and use it in GitHub Desktop.
a quick one off bash script to total hours in commit messages matching Time: [1.5] pattern per user
This file contains 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 | |
OIFS=$IFS; | |
IFS=$'\n'; | |
TAGS=$(git log --tags --simplify-by-decoration --pretty="format:%ci %d" | grep -o "\(tag:\s[v0-9\.]*\)" | sed "s/tag: //g") | |
CONTRIBUTORS=$(git shortlog -e -s | grep -o "<.*>"| sed 's/[<>]//g'); | |
OUTPUT=() | |
HEADER=("CONTRIBUTORS") | |
for name in $CONTRIBUTORS | |
do | |
HEADER=$(echo $HEADER $'\t' $name) | |
done | |
OUTPUT+=($HEADER) | |
last="" | |
for tag in $TAGS | |
do | |
tagline="$tag" | |
for name in $CONTRIBUTORS | |
do | |
CONTRIB=$(git log $tag..$last --author=$name --grep="^Time:" | grep -o "\[.*\]" | sed 's/\[//g' | sed 's/\]//g') | |
TOTAL=0 | |
for time in $CONTRIB | |
do | |
TOTAL=$(echo "$TOTAL+$time" | bc) | |
done; | |
tagline=$(echo $tagline $'\t' $TOTAL) | |
done | |
last=$tag | |
OUTPUT+=($tagline) | |
done | |
totalline="TOTAL" | |
for name in $CONTRIBUTORS | |
do | |
CONTRIB=$(git log --author=$name --grep="^Time:" | grep -o "\[.*\]" | sed 's/\[//g' | sed 's/\]//g') | |
TOTAL=0 | |
for time in $CONTRIB | |
do | |
TOTAL=$(echo "$TOTAL+$time" | bc) | |
done; | |
totalline=$(echo $totalline $'\t' $TOTAL) | |
done; | |
OUTPUT+=($totalline) | |
for line in ${OUTPUT[@]} | |
do | |
echo $line | |
done | column -t -s $'\t' | |
IFS=$OIFS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment