Skip to content

Commit

Permalink
Update contribs script
Browse files Browse the repository at this point in the history
  • Loading branch information
jarrodmillman committed Jan 1, 2020
1 parent dfc80fe commit 0a3d69c
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions doc/release/contribs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# https://github.com/scikit-image/scikit-image/blob/master/doc/release/contribs.py
import subprocess
from subprocess import check_output
import sys
import string
import shlex
Expand All @@ -10,45 +10,50 @@

tag = sys.argv[1]


def call(cmd):
return subprocess.check_output(shlex.split(cmd), universal_newlines=True).split('\n')
return check_output(shlex.split(cmd), universal_newlines=True).split("\n")


tag_date = call("git log -n1 --format='%%ci' %s" % tag)[0]
print("Release %s was on %s\n" % (tag, tag_date))
tag_date = call(f"git log -n1 --format='%ci' {tag}")[0]
print(f"Release {tag} was on {tag_date}\n")

merges = call("git log --since='%s' --merges --format='>>>%%B' --reverse" % tag_date)
merges = call(f"git log --since='{tag_date}' --merges --format='>>>%B' --reverse")
merges = [m for m in merges if m.strip()]
merges = '\n'.join(merges).split('>>>')
merges = [m.split('\n')[:2] for m in merges]
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)
num_commits = call(f"git rev-list {tag}..HEAD --count")[0]
print(f"A total of {num_commits} changes have been committed.\n")

commits = call("git log --since='%s' --pretty=%%s --reverse" % tag_date)
# Use filter to remove empty strings
commits = filter(None, call(f"git log --since='{tag_date}' --pretty=%s --reverse"))
for c in commits:
print('- ' + c)
print("- " + c)

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

print('- ' + message + 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 = call(f"git log --since='{tag_date}' --format=%aN")
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)
print("- " + a)

0 comments on commit 0a3d69c

Please sign in to comment.