Skip to content

Commit a9e5ac7

Browse files
committed
Add script to compute the number of additions per day
1 parent 8d3592c commit a9e5ac7

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Prints the number of additions per day.
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] += $5
31+
}
32+
END {
33+
for ( ts in lines ) {
34+
print ts OFS lines[ts]
35+
}
36+
}
37+
' | sort -n | perl -pe 's/(\d+)/gmtime($1)/e' | awk '{print $6 OFS $2 OFS $3 OFS $5}'

0 commit comments

Comments
 (0)