Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MRG] MNT Tools for working with what's new (#11800)
- Loading branch information
Showing
3 changed files
with
112 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
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,45 @@ | ||
#!/usr/bin/env python | ||
# Sorts what's new entries with per-module headings. | ||
# Pass what's new entries on stdin. | ||
|
||
import sys | ||
import re | ||
from collections import defaultdict | ||
|
||
LABEL_ORDER = ['MajorFeature', 'Feature', 'Enhancement', 'Efficiency', | ||
'Fix', 'API'] | ||
|
||
|
||
def entry_sort_key(s): | ||
if s.startswith('- |'): | ||
return LABEL_ORDER.index(s.split('|')[1]) | ||
else: | ||
return -1 | ||
|
||
|
||
# discard headings and other non-entry lines | ||
text = ''.join(l for l in sys.stdin | ||
if l.startswith('- ') or l.startswith(' ')) | ||
|
||
bucketed = defaultdict(list) | ||
|
||
for entry in re.split('\n(?=- )', text.strip()): | ||
modules = re.findall(r':(?:func|meth|mod|class):' | ||
r'`(?:[^<`]*<|~)?(?:sklearn.)?([a-z]\w+)', | ||
entry) | ||
modules = set(modules) | ||
if len(modules) > 1: | ||
key = 'Multiple modules' | ||
elif modules: | ||
key = ':mod:`sklearn.%s`' % next(iter(modules)) | ||
else: | ||
key = 'Miscellaneous' | ||
bucketed[key].append(entry) | ||
entry = entry.strip() + '\n' | ||
|
||
everything = [] | ||
for key, bucket in sorted(bucketed.items()): | ||
everything.append(key + '\n' + '.' * len(key)) | ||
bucket.sort(key=entry_sort_key) | ||
everything.extend(bucket) | ||
print('\n\n'.join(everything)) |
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,61 @@ | ||
#!/bin/bash | ||
# This script helps identify pull requests that were merged without a what's | ||
# new entry, where one would be appropriate. | ||
|
||
if [ $# -ne 2 ] | ||
then | ||
echo "Usage: GITHUB_TOKEN=... $0 <prev_release_ref> <whats_new_version>" >&2 | ||
exit 1 | ||
fi | ||
from_branch=$1 | ||
to_file=$2 | ||
|
||
logged_prs() { | ||
git log --oneline $from_branch..master sklearn/ | | ||
grep -wv -e CI -e DOC -e doc -e MNT -e MAINT -e BLD -e COSMIT -e EXA -e examples -e example -e minor -e STY -e Style -e docstring | | ||
grep -o '(#[0-9][0-9]\+)$' | | ||
grep -o '[0-9]\+' | ||
} | ||
|
||
mentioned_issues() { | ||
cat doc/whats_new/v$to_file.rst | | ||
grep -o 'issue:`[0-9]\+`' | | ||
grep -o '[0-9]\+' | ||
} | ||
|
||
get_closed_issues() { | ||
pr=$1 | ||
url=https://api.github.com/repos/scikit-learn/scikit-learn/pulls/$pr | ||
python - $url <<EOF | ||
import json | ||
import sys | ||
import re | ||
import os | ||
from urllib import request | ||
req = request.Request(sys.argv[1], headers={"Authorization": "token %s" % os.environ['GITHUB_TOKEN']}) | ||
body = json.loads(request.urlopen(req).read().decode('utf8'))['body'] | ||
body = re.sub('<!--.*?-->', '', body, flags=re.DOTALL) | ||
matches = re.findall(r'(?i)\\b(?:fix|fixes|resolve|resolves|close|closes) +(?:https?://github.com/scikit-learn/scikit-learn/(?:pull|issues)/|#)?([0-9]+)', | ||
body) | ||
print(' '.join(matches)) | ||
EOF | ||
} | ||
|
||
pr_numbers=$(diff <(logged_prs | sort) <(mentioned_issues | sort) | | ||
grep '<' | | ||
cut -c3- | | ||
grep -v -w -Ff <(git log --oneline $from_branch | grep -o '(#[0-9][0-9]\+)$' | grep -o '[0-9]\+') ) # drop things already released | ||
|
||
filtered_pr_numbers=$( | ||
for pr in $pr_numbers | ||
do | ||
echo $pr $(get_closed_issues $pr) | ||
done | | ||
grep -v -wFf <(mentioned_issues) | | ||
cut -d' ' -f1 | ||
) | ||
|
||
echo $filtered_pr_numbers | | ||
sed 's/[^ ]*/--grep (#&)/g' | | ||
xargs git log |