Commit | Line | Data |
---|---|---|
db1096e2 SK |
1 | #! /bin/sh |
2 | ||
3 | set -e | |
4 | ||
5 | root="$1" | |
6 | typ="$2" | |
7 | ||
8 | case "$typ" in | |
9 | 'commits') ;; | |
10 | 'changes') ;; | |
11 | '') typ='commits';; | |
12 | *) | |
13 | echo "Usage: $0 DIRECTORY [commits|changes]" >&2 | |
14 | exit 1 | |
15 | esac | |
16 | ||
17 | find "$root" -type d -name '.git' \ | |
18 | | while read -r dir | |
19 | do | |
20 | cd "$dir" || exit 1 | |
21 | git log --format=%ci --numstat | |
22 | done \ | |
23 | | gawk ' | |
24 | /^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} / { | |
25 | date = $1 | |
26 | split(date, d, "-") | |
27 | year = d[1] | |
28 | commits[year]++ | |
29 | } | |
30 | ||
31 | /^[0-9]+\s+[0-9]+\s+/ { | |
32 | additions = $1 | |
33 | deletions = $2 | |
34 | changes[year] += additions + deletions | |
35 | } | |
36 | ||
37 | END { | |
38 | for (year in changes) { | |
39 | print year, "commits", commits[year] | |
40 | print year, "changes", changes[year] | |
41 | } | |
42 | }' \ | |
43 | | awk -v type_selected="$typ" ' | |
44 | { | |
45 | year = $1 | |
46 | type = $2 | |
47 | value = $3 | |
48 | d[year, type] = value | |
49 | if (value > max[type]) | |
50 | max[type] = value | |
51 | } | |
52 | ||
53 | END { | |
54 | for (yeartype in d) { | |
55 | split(yeartype, yt, SUBSEP) | |
56 | year = yt[1] | |
57 | type = yt[2] | |
58 | value = d[yeartype] | |
59 | if (type == type_selected) { | |
60 | printf "%s ", year | |
61 | for (i = 1; i <= (value * 100) / max[type]; i++) { | |
62 | printf "|" | |
63 | } | |
64 | printf "\n" | |
65 | } | |
66 | } | |
67 | }' \ | |
68 | | sort -n -k 1 |