forked from numba/numba
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moving from the Gist at: https://gist.github.com/sklam/e526a302eaefd405dbb2bae52d075012 To the `numba/maint` directory.
- Loading branch information
Showing
1 changed file
with
123 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
#! /usr/bin/env python | ||
|
||
import sys, os | ||
from datetime import datetime, timedelta | ||
from pprint import pprint | ||
from getpass import getpass | ||
|
||
from github3 import login | ||
import github3 | ||
|
||
|
||
def fetch(target_repo, last_num, gh): | ||
orgname, reponame = target_repo.split('/', 1) | ||
|
||
repo = gh.repository(orgname, reponame) | ||
issues = repo.issues(state='all') | ||
|
||
opened_issues = [] | ||
closed_issues = [] | ||
|
||
opened_prs = [] | ||
closed_prs = [] | ||
|
||
max_iss_num = 0 | ||
for issue in issues: | ||
info = issue.as_dict() | ||
iss_num = int(info['number']) | ||
max_iss_num = max(max_iss_num, iss_num) | ||
|
||
if iss_num <= last_num: | ||
break | ||
merged = False | ||
if issue.pull_request_urls: | ||
# Is PR? | ||
merged = bool(info['pull_request'].get("merged_at")) | ||
where = {'opened': opened_prs, 'closed': closed_prs} | ||
else: | ||
# Is Issues | ||
where = {'opened': opened_issues, 'closed': closed_issues} | ||
|
||
fmt = '- [{}#{}]({}) - {}' | ||
if merged: | ||
fmt = "- merged " + fmt | ||
line = fmt.format( | ||
reponame, | ||
info['number'], | ||
info['html_url'], | ||
info['title'], | ||
) | ||
|
||
# Is issue already merged | ||
if issue.is_closed(): | ||
where['closed'].append(line) | ||
else: | ||
where['opened'].append(line) | ||
|
||
return { | ||
'opened_issues': opened_issues, | ||
'closed_issues': closed_issues, | ||
'opened_prs': opened_prs, | ||
'closed_prs': closed_prs, | ||
'max_iss_num': max_iss_num, | ||
} | ||
|
||
def display(data): | ||
print("## 1. New Issues") | ||
for line in reversed(data['opened_issues']): | ||
print(line) | ||
print() | ||
|
||
print("### Closed Issues") | ||
for line in reversed(data['closed_issues']): | ||
print(line) | ||
print() | ||
|
||
print("## 2. New PRs") | ||
for line in reversed(data['opened_prs']): | ||
print(line) | ||
print() | ||
|
||
print("### Closed PRs") | ||
for line in reversed(data['closed_prs']): | ||
print(line) | ||
print() | ||
|
||
|
||
def main(numba_last_num, llvmlite_last_num, user=None, password=None): | ||
|
||
if user is not None and password is not None: | ||
gh = login(str(user), password=str(password)) | ||
else: | ||
gh = github3 | ||
numba_data = fetch("numba/numba", numba_last_num, gh) | ||
llvmlite_data = fetch("numba/llvmlite", llvmlite_last_num, gh) | ||
|
||
# combine data | ||
data = { | ||
'opened_issues': llvmlite_data['opened_issues'] + numba_data['opened_issues'], | ||
'closed_issues': llvmlite_data['closed_issues'] + numba_data['closed_issues'], | ||
'opened_prs': llvmlite_data['opened_prs'] + numba_data['opened_prs'], | ||
'closed_prs': llvmlite_data['closed_prs'] + numba_data['closed_prs'], | ||
} | ||
|
||
display(data) | ||
|
||
print(f"(last numba: {numba_data['max_iss_num']}; llvmlite {llvmlite_data['max_iss_num']})") | ||
|
||
help_msg = """ | ||
Usage: | ||
{program_name} <numba_last_num> <llvmlite_last_num> | ||
""" | ||
|
||
if __name__ == '__main__': | ||
program_name = sys.argv[0] | ||
try: | ||
[numba_last_num, llvmlite_last_num] = sys.argv[1:] | ||
except ValueError: | ||
print(help_msg.format(program_name=program_name)) | ||
else: | ||
main(int(numba_last_num), | ||
int(llvmlite_last_num), | ||
user=os.environ.get("GHUSER"), | ||
password=os.environ.get("GHPASS")) |