Skip to content

Instantly share code, notes, and snippets.

@radekg
Last active August 29, 2015 14:07
Show Gist options
  • Save radekg/908bfa6deba5976a2b27 to your computer and use it in GitHub Desktop.
Save radekg/908bfa6deba5976a2b27 to your computer and use it in GitHub Desktop.
List of contributors to a github project grouped by the company

List contributors

Output explained:

project_name contributors:
 --------------------------- 
Company name (if set on user profile)
  Member
  Member
  Member
  ...
Company name (if set on user profile)
  ...
...

It may be worth going through the email addresses of the users who did not set the company on their profiles. Some of them expose the company. '' and None are no company set users.

from github import Github
# Your Github token:
GITHUB_TOKEN = "..."
gh = Github(login_or_token=GITHUB_TOKEN)
# Set your own projects here:
projects = [ "apache/cassandra",
"apache/hadoop",
"apache/hadoop-common",
"apache/hadoop-hdfs",
"apache/hadoop-mapreduce",
"apache/hbase",
"apache/kafka",
"apache/mesos",
"apache/spark",
"apache/zookeeper",
"mongodb/mongo",
"opscode/chef",
"openstack/horizon",
"openstack/nova",
"openstack/ceilometer",
"openstack/glance",
"openstack/neutron",
"openstack/heat",
"openstack/sahara",
"openstack/swift",
"openstack/keystone",
"openstack/cinder" ]
statistics_only = True
for project in projects:
repo = gh.get_repo( project )
index = 1
by_company = {}
print "{} contributors:".format( project )
print " --------------------------- "
for c in repo.get_contributors():
name = c.name.encode('utf-8').strip() if c.name != None else None
company = c.company.encode('utf-8').strip() if c.company != None else None
email = c.email.encode('utf-8').strip() if c.email != None else None
if company not in by_company:
by_company[ company ] = []
by_company[ company ].append( " Name: {}, login: {}, email address: {}".format( name, c.login, email ) )
companies = by_company.keys()
companies.sort()
if not statistics_only:
for key in companies:
print "{} (if set on user profile)".format( key )
for line in by_company[ key ]:
print line
print ""
total = 0
for key in companies:
print "{}: {} contributors".format( key, len( by_company[ key ] ) )
total = total + len( by_company[ key ] )
print "Total contibutors: {}".format( total )
print ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment