summaryrefslogtreecommitdiff
path: root/git-author-stats
blob: 8bd2d9b256e658041da7df5bc24f79e3d6296c20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env bash

script=$(cat << 'EOF'
NF == 1 { name = $1; commits[name] += 1 }
NF == 3 { plus[name] += $1; minus[name] += $2 }
END {
  for (name in plus) {
    print name "\t+" plus[name] "\t-" minus[name] "\t" commits[name]
  }
}
EOF
)

(printf $'name\tadded\tremoved\tcommits\n';

git log --numstat --pretty=$'%aN' "$@" \
    | awk -F$'\t' "$script" \
    | sort --field-separator=$'\t' -k${ASTATS_SORT_COLUMN:-2} -gr
) > /tmp/git-author-stats

column -t -s $'\t' /tmp/git-author-stats
rm /tmp/git-author-stats