File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed
Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ #
3+ # Prints the approximate number of packages per month per author.
4+ #
5+ # <month> <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 monthly totals.
17+ # * `sort -k1n -k2M`
18+ # - Sort the year numerically and sort the second key as a month.
19+ # * `awk '{}'`
20+ # - Format the output.
21+ " ${pkg_json} " | awk '
22+ {
23+ mon = $5 OFS $2
24+ }
25+
26+ # Added a `package.json`:
27+ $8 == "A" {
28+ pkgs[mon,$6,$7] += 1
29+ }
30+
31+ # Deleted a `package.json`:
32+ $8 == "D" {
33+ pkgs[mon,$6,$7] -= 1
34+ }
35+
36+ END {
37+ for (k in pkgs) {
38+ split(k, keys, SUBSEP)
39+ print keys[1] OFS keys[2] OFS keys[3] OFS pkgs[k]
40+ }
41+ }
42+ ' | sort -k1n -k2M | awk ' {print $2 OFS $1 OFS $3 OFS $4 OFS $5}'
You can’t perform that action at this time.
0 commit comments