Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A quick script for seeing the intersection between contributors to different GitHub repositories
from github import Github
from collections import Counter
import sys
USER = None
PASSWORD = None
def get_repo(repo_name):
contribs = list(g.get_repo(repo_name).get_contributors())
return {'contribs': [c.login for c in contribs]}
g = Github(USER, PASSWORD)
repos = [get_repo(r) for r in sys.argv[1:]]
print("Contributors in all of:", ", ".join(sys.argv[1:]))
contribs = set(repos[0]["contribs"])
for repo in repos[1:]:
contribs &= set(repo["contribs"])
for contrib in contribs:
print("-", contrib)
print("")
print("Furthermore, the most nomadic contributors:")
print("")
nomadic = Counter()
for repo in repos:
for contrib in repo["contribs"]:
nomadic[contrib] += 1
for (user, n) in nomadic.most_common():
print("- %s (%d repositories)" % (user, n))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.