Skip to content

Instantly share code, notes, and snippets.

@loic
Created August 20, 2013 07:47
Show Gist options
  • Save loic/6278288 to your computer and use it in GitHub Desktop.
Save loic/6278288 to your computer and use it in GitHub Desktop.
#!/bin/sh
function list_contributors {
git log | grep "Author:" | sed "s/ //" | sed "s/ <.*//" | sort | uniq -c | sort
}
function total_contributors {
list_contributors | wc -l | sed 's/ *//'
}
function core_developers {
grep ' \* ' AUTHORS | wc -l | sed 's/ *//'
}
function normal_contributors {
echo `total_contributors` - `core_developers` | bc
}
function number_of_contributions {
local contributions=$(seq -s '|' $1 | sed 's/\|$//')
local contributors=$(list_contributors | egrep " ($contributions) Author" | wc -l | sed 's/ *//')
local percent=$(echo "scale=2; $contributors*100/`normal_contributors`" | bc)
echo "$contributors ($percent%)"
}
echo "Total contributors:"
total_contributors
echo
echo "Core developers:"
core_developers
echo
echo "Normal contributors:"
normal_contributors
echo
echo "New contributors with 1 contribution:"
number_of_contributions 1
echo
echo "New contributors with 2 contributions:"
number_of_contributions 2
echo
echo "New contributors with 3 contributions:"
number_of_contributions 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment