Skip to content

Commit 803eeaa

Browse files
committed
Simplify script
1 parent 1c499d9 commit 803eeaa

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

tools/git/scripts/additions_per_day

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,20 @@ shortstats="${root}/tools/git/scripts/shortstats"
1212
# - Get summary statistics for each commit.
1313
# * `awk '{}'`
1414
# - Tabulate the daily totals.
15-
# * `sort -n`
16-
# - Sort in numeric order.
17-
# * `perl -pe ''`
18-
# - Convert each Unix timestamp to a date string.
15+
# * `sort -k1n -k2M`
16+
# - Sort the year numerically and sort the second key as a month.
1917
# * `awk '{}'`
2018
# - Format the output.
2119
"${shortstats}" | awk '
22-
BEGIN {
23-
scalar = 60 * 60 * 24
24-
}
2520
{
26-
# Round a Unix timestamp to the nearest day:
27-
ts = int($1/scalar) * scalar
21+
day = $5 OFS $2 OFS $3
2822
2923
# Update daily totals:
30-
lines[ts] += $5
24+
lines[day] += $9
3125
}
3226
END {
33-
for (ts in lines) {
34-
print ts OFS lines[ts]
27+
for (day in lines) {
28+
print day OFS lines[day]
3529
}
3630
}
37-
' | sort -n | perl -pe 's/(\d+)/localtime($1)/e' | awk '{print $2 OFS $3 OFS $5 OFS $6}'
31+
' | sort -k1n -k2M | awk '{print $2 OFS $3 OFS $1 OFS $4}'

0 commit comments

Comments
 (0)