Skip to content

Commit f7d790a

Browse files
committed
Add script
1 parent 4ad34ba commit f7d790a

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Prints the approximate number of tools packages per year per author.
4+
#
5+
# <year> <author_first_name> <author_last_name> <num_pkgs>
6+
7+
# Determine root directory:
8+
root="$(git rev-parse --show-toplevel)"
9+
10+
# Define the path to a utility to find when `package.json` files were added and deleted:
11+
pkg_json="${root}/tools/git/scripts/pkg_json_added_deleted"
12+
13+
# * `pkg_json`
14+
# - `package.json` additions and deletions.
15+
# * `awk '{}'`
16+
# - Tabulate the yearly totals.
17+
# * `sort -k1n`
18+
# - Sort the year numerically.
19+
# * `awk '{}'`
20+
# - Format the output.
21+
"${pkg_json}" | awk '
22+
{
23+
yr = $5
24+
}
25+
26+
# Skip non-tools `package.json`:
27+
$9 !~ /^tools\// {
28+
next
29+
}
30+
31+
# Added a `package.json`:
32+
$8 == "A" {
33+
pkgs[yr,$6,$7] += 1
34+
}
35+
36+
# Deleted a `package.json`:
37+
$8 == "D" {
38+
pkgs[yr,$6,$7] -= 1
39+
}
40+
41+
END {
42+
for (k in pkgs) {
43+
split(k, keys, SUBSEP)
44+
print keys[1] OFS keys[2] OFS keys[3] OFS pkgs[k]
45+
}
46+
}
47+
' | sort -k1n | awk '{print $1 OFS $2 OFS $3 OFS $4}'

0 commit comments

Comments
 (0)