summaryrefslogtreecommitdiff
path: root/git-author-stats
blob: ede4ef23a4d63ecd1a9f71881378ef976d92e3fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env bash
#
# Print lines added/removed and number of commits by author. Optional arg is a
# path passed to 'git log'.
#
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
)
column -t -s $'\t' <(
  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
)