Last active
July 9, 2020 09:14
-
-
Save ShinJJang/97d10bcc81b25fd5c53d17ba580f50c4 to your computer and use it in GitHub Desktop.
Get pull requests with PyGithub, python3 📒
This file contains hidden or 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
#!/usr/bin/env python3 | |
from github import Github | |
token = 'YOUR TOKEN' # https://github.com/settings/tokens | |
username = 'YOUR USERNAME' | |
organization = 'YOUR TEAM' | |
gh = Github(token) # or Github(username, password) | |
query = 'org:{} is:merged'.format(organization) # https://help.github.com/en/articles/searching-issues-and-pull-requests | |
issues = list(gh.search_issues(query, author=username, type='pr')) | |
for issue in issues: | |
print(issue.number, issue.state, issue.title, issue.html_url) | |
print('Count : {}'.format(len(issues))) |
Github enterprise version
- In specific repo,
- Created than ~
- Merged than ~
#!/usr/bin/env python3
from github import Github
token = 'YOUR TOKEN' # https://github.com/settings/tokens
organization = 'YOUR TEAM'
repo = 'YOUR REPO'
gh = Github(token, base_url='[YOUR Github Domain]/api/v3') # or Github(username, password)
count = 0
print('-------merged------')
query = 'repo:{}/{} is:merged merged:>=2020-06-17'.format(organization, repo) # https://help.github.com/en/articles/searching-issues-and-pull-requests
issues = list(gh.search_issues(query, type='pr'))
for issue in issues:
print(issue.number, issue.state, issue.user.name, issue.created_at.date(), issue.title)
count += len(issues)
print('------opend-------')
query = 'repo:{}/{} is:unmerged created:>=2020-06-17'.format(organization, repo) # https://help.github.com/en/articles/searching-issues-and-pull-requests
issues = list(gh.search_issues(query, type='pr'))
for issue in issues:
print(issue.number, issue.state, issue.user.name, issue.created_at.date(), issue.title)
count += len(issues)
print('Count : {}'.format(count))
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Prerequisites 📦
Execute ⚡