Skip to content

Instantly share code, notes, and snippets.

@aks
Last active April 8, 2023 01:52
Show Gist options
  • Save aks/d1ac5e4f78f08796e90248afd847cef6 to your computer and use it in GitHub Desktop.
Save aks/d1ac5e4f78f08796e90248afd847cef6 to your computer and use it in GitHub Desktop.
Bash script to show the top-committers in a repo, in descending frequency of commits
#!/usr/bin/env bash
# top-committers [NUMBER]
count=${1:-200}
git log --pretty=format:"%ae %at" |
awk 'BEGIN { FS=" "; OFS="," }
!seen[$1]++ { first[$1]=$2 }
{ last[$1]=$2; count[$1]++ }
END {
for (email in first) print email, first[email], last[email], count[email]
}' |
while IFS=, read -r email first last count; do
printf "%s | %s | %s | %s\n" "$email" "$(date -u -r $first '+%Y-%m-%d')" "$(date -u -r $last '+%Y-%m-%d')" "$count";
done 2>/dev/null |
sort -bnr -k 7 |
head -$count |
column -t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment