Skip to content

Instantly share code, notes, and snippets.

@jeanlauliac
Last active December 27, 2015 07:49
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 jeanlauliac/7292123 to your computer and use it in GitHub Desktop.
Save jeanlauliac/7292123 to your computer and use it in GitHub Desktop.
Compute git commit volumes for each hour of the week.
#!/bin/bash
git log --format=format:"%aD" | gawk '
match($0, /^([[:alnum:]]{3}), [[:digit:]]+ [[:alpha:]]{3} \
[[:digit:]]+ ([[:digit:]]+):[[:digit:]]+:[[:digit:]]+/, mt) {
days[mt[1]]["count"]++;
days[mt[1]]["hours"][+mt[2]]++;
total["count"]++;
total["hours"][+mt[2]]++;
}
function print_day(name, day) {
printf "%s,%d", name, day["count"];
for (hour = 0; hour < 24; hour++) {
printf ",%d", day["hours"][hour];
}
printf "\n"
}
END {
for (day in days)
print_day(day, days[day]);
print_day("total", total);
}
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment