Last active
April 26, 2016 21:08
-
-
Save giwa/8d9af1a037de7440499a4eeba655cf49 to your computer and use it in GitHub Desktop.
Fetch PR from Github filtered by labels using PyGithub ref: http://qiita.com/giwa/items/50167309774927a5a203
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from github import Github | |
token = 'YOUR_TOKEN' | |
g = Github(token) | |
repos = ['YOUR_REPO', 'YOUR_REPO'] | |
# You can change get_organization to get_user() | |
org = g.get_organization('YOUR_ORG') | |
git_repos ={repo: org.get_repo(repo) for repo in repos} | |
# Issue is a equivalent to pr | |
# Issue API should be called first to fetch tags | |
def get_pr_from_issues(issues): | |
for issue in issues: | |
if issue.pull_request is not None: | |
pr_id = int(issue.pull_request.html_url.split("/")[-1]) | |
yield issue.repository.get_pull(pr_id), issue.labels | |
repo_prs = {} | |
for repo_name, repo in git_repos.items(): | |
repo_prs[repo_name] = get_pr_from_issues(repo.get_issues(state='open')) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment