Skip to content

Commit 5467cb6

Browse files
committed
Add script to compute summary statistics per author per year
1 parent 8f72482 commit 5467cb6

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Prints the summary statistics per year per author.
4+
#
5+
# <year> <author_first_name> <author_last_name> <num_commits> <files_changed> <additions> <deletions>
6+
7+
# Determine root directory:
8+
root="$(git rev-parse --show-toplevel)"
9+
10+
# Define the path to a utility to generate commit short stats:
11+
shortstats="${root}/tools/git/scripts/shortstats"
12+
13+
# * `shortstats`
14+
# - Get summary statistics for each commit.
15+
# * `awk '{}'`
16+
# - Tabulate the yearly totals.
17+
# * `sort -k1n`
18+
# - Sort the year numerically.
19+
"${shortstats}" | awk '
20+
{
21+
# Update yearly totals per author:
22+
commits[$5,$6,$7] += 1
23+
files[$5,$6,$7] += $8
24+
additions[$5,$6,$7] += $9
25+
deletions[$5,$6,$7] += $10
26+
}
27+
END {
28+
for (k in commits) {
29+
split(k, keys, SUBSEP)
30+
print keys[1] OFS keys[2] OFS keys[3] OFS commits[k] OFS files[k] OFS additions[k] OFS deletions[k]
31+
}
32+
}
33+
' | sort -k1n

0 commit comments

Comments
 (0)