summaryrefslogtreecommitdiff
path: root/git-author-stats
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2020-03-09 15:47:26 -0700
committerBen Sima <ben@bsima.me>2020-03-09 15:47:26 -0700
commit04d8f0a6f7886c37de0053852649688a4ffff603 (patch)
tree3687786417b565bd6cfef54f7748445b9597a339 /git-author-stats
parentdda68b4bebb5700de6a7dd3c22fbaf8a0de1d211 (diff)
Add git-author-stats
via: https://github.com/jb55/bin/blob/master/git-author-stats
Diffstat (limited to 'git-author-stats')
-rwxr-xr-xgit-author-stats22
1 files changed, 22 insertions, 0 deletions
diff --git a/git-author-stats b/git-author-stats
new file mode 100755
index 0000000..8bd2d9b
--- /dev/null
+++ b/git-author-stats
@@ -0,0 +1,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