Skip to content

Commit 559fecb

Browse files
committed
Add script compute the number of commits per day per author
1 parent c3b1ab8 commit 559fecb

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Prints the number of commits per day per author.
4+
5+
# Determine root directory:
6+
root="$(git rev-parse --show-toplevel)"
7+
8+
# Define the path to a utility to generate commit short stats:
9+
shortstats="${root}/tools/git/scripts/shortstats"
10+
11+
# * `shortstats`
12+
# - Get summary statistics for each commit.
13+
# * `awk '{}'`
14+
# - Tabulate the daily totals.
15+
# * `sort -n`
16+
# - Sort in numeric order.
17+
# * `perl -pe ''`
18+
# - Convert each Unix timestamp to a date string.
19+
# * `awk '{}'`
20+
# - Format the output.
21+
"${shortstats}" | awk '
22+
BEGIN {
23+
scalar = 60 * 60 * 24
24+
}
25+
{
26+
# Round a Unix timestamp to the nearest day:
27+
ts = int($1/scalar) * scalar
28+
29+
# Update daily totals:
30+
lines[ts,$2,$3] += 1
31+
}
32+
END {
33+
for ( k in lines ) {
34+
split(k, keys, SUBSEP)
35+
print keys[1] OFS keys[2] OFS keys[3] OFS lines[k]
36+
}
37+
}
38+
' | sort -n | perl -pe 's/(\d+)/gmtime($1)/e' | awk '{print $2 OFS $3 OFS $5 OFS $6 OFS $7 OFS $8}'

0 commit comments

Comments
 (0)