Skip to content

Instantly share code, notes, and snippets.

@sbesson
Last active December 26, 2015 05:49
Show Gist options
  • Save sbesson/7103109 to your computer and use it in GitHub Desktop.
Save sbesson/7103109 to your computer and use it in GitHub Desktop.
from scc.git import get_github, get_token
from scc.git import PullRequest
gh = get_github(get_token())
# List all PRs in the organizations
orgs = ["openmicroscopy", "ome"]
print "Listing all PRs in organizations: %s" % ", ".join(orgs)
all_prs = []
for org in orgs:
for repo in gh.get_organization(org).get_repos():
for pull in repo.get_pulls():
all_prs.append(PullRequest(pull))
# Filter PR by label
exclude_labels = [u'exclude', u'ON_HOLD']
print "Removing PRs labeled as: %s" % ", ".join(exclude_labels)
def check_labels(labels):
return bool(set(labels) & set(exclude_labels))
valid_prs = [pr for pr in all_prs if not check_labels(pr.get_labels())]
# Filter PR by user
exclude_users = [u'snoopycrimecop']
print "Removing PRs opened by: %s" % ", ".join(exclude_users)
valid_prs = [pr for pr in valid_prs if not pr.get_login() in exclude_users]
# List PRs by base
bases = [u'dev_4_4', u'develop', u'master']
print "Sorting PRs by base"
for base in bases:
print base
prs = [pr for pr in valid_prs if pr.get_base() == base]
for index, pr in enumerate(prs):
print '\t#%s [???] [%s] %s (%s)' \
% (index + 1, pr.base.repo.name, pr.get_title(),
pr.get_login())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment