Skip to content

Commit 63aa385

Browse files
committed
Simplify script
1 parent 081832a commit 63aa385

1 file changed

Lines changed: 6 additions & 12 deletions

File tree

tools/git/scripts/author_commits_per_day

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,21 @@ 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
29-
# Update daily totals:
30-
lines[ts,$2,$3] += 1
23+
# Update daily totals per author:
24+
lines[day,$6,$7] += 1
3125
}
3226
END {
3327
for (k in lines) {
3428
split(k, keys, SUBSEP)
3529
print keys[1] OFS keys[2] OFS keys[3] OFS lines[k]
3630
}
3731
}
38-
' | sort -n | perl -pe 's/(\d+)/localtime($1)/e' | awk '{print $2 OFS $3 OFS $5 OFS $6 OFS $7 OFS $8}'
32+
' | sort -k1n -k2M | awk '{print $2 OFS $3 OFS $1 OFS $4 OFS $5 OFS $6}'

0 commit comments

Comments
 (0)