Skip to content

Commit

Permalink
Try using GitHub API to get PR/contibutors list
Browse files Browse the repository at this point in the history
  • Loading branch information
jarrodmillman committed Jul 24, 2017
1 parent fb8ecc3 commit c62d590
Showing 1 changed file with 18 additions and 46 deletions.
64 changes: 18 additions & 46 deletions doc/release/contribs.py
Original file line number Diff line number Diff line change
@@ -1,51 +1,23 @@
#!/usr/bin/env python
# https://github.com/scikit-image/scikit-image/blob/master/doc/release/contribs.py
import subprocess
import sys
import string
import shlex
import requests

if len(sys.argv) != 2:
print("Usage: ./contributors.py tag-of-previous-release")
sys.exit(-1)
# Was
# - Cherry pick missing commits (#2535)

tag = sys.argv[1]
# Now
# - Cherry pick missing commits (#2535) [jarrodmillman in 6287d8f9] []
# - Update graphml to care for a number of issues. (#2515) [dschult in 7be0d8f3] [u'Enhancement', u'Maintenance']

def call(cmd):
return subprocess.check_output(shlex.split(cmd), universal_newlines=True).split('\n')
page = 1
for page in range(1, 10):

tag_date = call("git log -n1 --format='%%ci' %s" % tag)[0]
print("Release %s was on %s\n" % (tag, tag_date))
print("Page " + str(page))
r = requests.get('https://api.github.com/repos/networkx/networkx/issues/events?state=merged&per_page=100&page={}'.format(page))
page += 1

merges = call("git log --since='%s' --merges --format='>>>%%B' --reverse" % tag_date)
merges = [m for m in merges if m.strip()]
merges = '\n'.join(merges).split('>>>')
merges = [m.split('\n')[:2] for m in merges]
merges = [m for m in merges if len(m) == 2 and m[1].strip()]

num_commits = call("git rev-list %s..HEAD --count" % tag)[0]
print("A total of %s changes have been committed.\n" % num_commits)

print("It contained the following %d merges:\n" % len(merges))
for (merge, message) in merges:
if merge.startswith('Merge pull request #'):
PR = ' (%s)' % merge.split()[3]
else:
PR = ''

print('- ' + message + PR)

print("\nMade by the following committers [alphabetical by last name]:\n")

authors = call("git log --since='%s' --format=%%aN" % tag_date)
authors = [a.strip() for a in authors if a.strip()]

def key(author):
author = [v for v in author.split() if v[0] in string.ascii_letters]
if len(author) > 0:
return author[-1]

authors = sorted(set(authors), key=key)

for a in authors:
print('- ' + a)
for item in r.json():
if item['event'] == 'merged':
print('- {} (#{}) [{} in {}] {}'.format(item['issue']['title'],
item['issue']['number'],
item['actor']['login'],
item['commit_id'][:8],
[l['name'] for l in item['issue']['labels']]))

0 comments on commit c62d590

Please sign in to comment.