Skip to content

Instantly share code, notes, and snippets.

@koraa
Created August 1, 2014 02:07
Show Gist options
  • Save koraa/6f66cdc7f99848035892 to your computer and use it in GitHub Desktop.
Save koraa/6f66cdc7f99848035892 to your computer and use it in GitHub Desktop.
List the lines of code per author in the current head
#! /bin/bash
# List the amount of code per author in the current HEAD
git ls-files "$@" | xargs -l1 git blame -s -- | awk '
function get_author(commit) {
author = commit_map[commit]
if (author == "") {
cmd = "git show -s --pretty=format:%ae " commit
cmd | getline author
commit_map[commit] = author
close(cmd)
}
return author
}
{
author = get_author($1)
counter[author] = counter[author] + 1
if (counter[author] % 500 == 0)
print($1 " -> " author " -> " counter[author]) | "cat >&2"
}
END {
for (author in counter) {
print counter[author] " " author
}
}
' | sort -n | column -t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment