8000 Support GitHub Issues by Mariatta · Pull Request #431 · python/core-workflow · GitHub
[go: up one dir, main page]

Skip to content

Support GitHub Issues #431

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
- '3.7'
- '3.8'
- '3.9'
- '3.10'
name: ${{ matrix.python }}
runs-on: ubuntu-latest
steps:
Expand Down
24 changes: 15 additions & 9 deletions blurb/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Under ``Misc/NEWS.d`` you'll find the following:
the various ``Misc/NEWS`` categories. Inside these subdirectories
are more ``.rst`` files with long, uninteresting, computer-generated
names. Example:
``Misc/NEWS.d/next/Library/2017-05-04-12-24-06.bpo-25458.Yl4gI2.rst``
``Misc/NEWS.d/next/Library/2017-05-04-12-24-06.gh-25458.Yl4gI2.rst``


blurb subcommands
Expand Down Expand Up @@ -85,9 +85,9 @@ in the correct place, and stages it in ``git`` for you.
The template for the ``blurb add`` message looks like this::

#
# Please enter the relevant bugs.python.org issue number here:
# Please enter the relevant GitHub issue number here:
#
.. bpo:
.. issue:

#
# Uncomment one of these "section:" lines to specify which section
Expand All @@ -106,13 +106,13 @@ The template for the ``blurb add`` message looks like this::
#.. section: C API

# Write your Misc/NEWS entry below. It should be a simple ReST paragraph.
# Don't start with "- Issue #<n>: " or "- bpo-<n>: "or that sort of stuff.
# Don't start with "- Issue #<n>: " or "- gh-<n>: "or that sort of stuff.
###########################################################################

Here's how you interact with the file:

* Add the ``bugs.python.org`` issue number for this checkin to the
end of the ``.. bpo:`` line.
* Add the GitHub issue number for this checkin to the
end of the ``.. issue:`` line.

* Uncomment the line with the relevant ``Misc/NEWS`` section for this entry.
For example, if this should go in the ``Library`` section, uncomment
Expand All @@ -126,11 +126,11 @@ Here's how you interact with the file:
When ``blurb add`` gets a valid entry, it writes it to a file
with the following format::

Misc/NEWS.d/next/<section>/<datetime>.bpo-<bpo>.<nonce>.rst
Misc/NEWS.d/next/<section>/<datetime>.gh-<issue_number>.<nonce>.rst

For example, a file added by ``blurb add`` might look like this::

Misc/NEWS.d/next/Library/2017-05-04-12-24-06.bpo-25458.Yl4gI2.rst
Misc/NEWS.d/next/Library/2017-05-04-12-24-06.gh-25458.Yl4gI2.rst

``<section>`` is the section provided in the checkin message.

Expand Down Expand Up @@ -172,7 +172,7 @@ for the "sections" inside each release, whereas ``blurb merge``
has a hard-coded preferred ordering for the sections. Also,
**blurb** aggressively reflows paragraphs to < 78 columns,
wheras the original hand-edited file occasionally had lines
> 80 columns. Finally, **blurb** strictly uses ``bpo-<n>:`` to
> 80 columns. Finally, **blurb** strictly uses ``gh-<n>:`` to
specify issue numbers at the beginnings of entries, wheras
the legacy approach to ``Misc/NEWS`` required using ``Issue #<n>:``.

Expand Down Expand Up @@ -247,6 +247,12 @@ part of the cherry-picking process.
Changelog
---------

1.1.0
~~~~~

- Support GitHub Issues instead of B.P.O. The metadata now contains "issue"
instead of "bpo". The Misc/News filename now uses `gh-<number>` instead of `bpo-<number>`

1.0.7
~~~~~

Expand Down
108 changes: 54 additions & 54 deletions blurb/blurb.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
"""Command-line tool to manage CPython Misc/NEWS.d entries."""
__version__ = "1.0.8"
__version__ = "1.1.0"

##
## blurb version 1.0
Expand Down Expand Up @@ -73,9 +73,9 @@
template = """

#
# Please enter the relevant bugs.python.org issue number here:
# Please enter the relevant GitHub issue number here:
#
.. bpo:
.. issue:

#
# Uncomment one of these "section:" lines to specify which section
Expand All @@ -94,7 +94,7 @@
#.. section: C API

# Write your Misc/NEWS entry below. It should be a simple ReST paragraph.
# Don't start with "- Issue #<n>: " or "- bpo-<n>: " or that sort of stuff.
# Don't start with "- Issue #<n>: " or "- gh-<n>: " or that sort of stuff.
###########################################################################


Expand Down Expand Up @@ -408,11 +408,11 @@ class BlurbError(RuntimeError):
* Trailing whitespace is stripped. Leading whitespace is preserved.
* Empty lines between non-empty lines are preserved.
Trailing empty lines are stripped.
* The BODY mustn't start with "Issue #", "bpo-", or "- ".
* The BODY mustn't start with "Issue #", "gh-", or "- ".
(This formatting will be inserted when rendering the final output.)
* Lines longer than 76 characters will be wordwrapped.
* In the final output, the first line will have
"- bpo-<bpo-number>: " inserted at the front,
"- gh-<gh-number>: " inserted at the front,
and subsequent lines will have two spaces inserted
at the front.

Expand All @@ -423,11 +423,11 @@ class BlurbError(RuntimeError):

The format of a "next" file is exactly the same, except that we're storing
four pieces of metadata in the filename instead of in the metadata section.
Those four pieces of metadata are: section, bpo, date, and nonce.
Those four pieces of metadata are: section, issue, date, and nonce.

-----------------------------------------------------------------------------

In addition to the four conventional metadata (section, bpo, date, and nonce),
In addition to the four conventional metadata (section, issue, date, and nonce),
there are two additional metadata used per-version: "release date" and
"no changes". These may only be present in the metadata block in the *first*
blurb in a blurb file.
Expand All @@ -436,7 +436,7 @@ class BlurbError(RuntimeError):
for this version. When used, there are two more things that must be
true about the the blurb file:
* There should only be one entry inside the blurb file.
* That entry's bpo number must be 0.
* That entry's issue number must be 0.

"""

Expand Down Expand Up @@ -467,7 +467,7 @@ def finish_entry():
if not body:
throw("Blurb 'body' text must not be empty!")
text = textwrap_body(body)
for naughty_prefix in ("- ", "Issue #", "bpo-"):
for naughty_prefix in ("- ", "Issue #", "bpo-", "gh-"):
if text.startswith(naughty_prefix):
throw("Blurb 'body' can't start with " + repr(naughty_prefix) + "!")

Expand All @@ -480,11 +480,11 @@ def finish_entry():
elif section not in sections:
throw("Invalid 'section'! You must use one of the predefined sections.")

bpo = None
issue_number = None
try:
bpo = int(metadata.get('bpo'))
issue_number = int(metadata.get('issue'))
except (TypeError, ValueError):
throw("Invalid bpo issue number! (" + repr(bpo) + ")")
throw("Invalid GitHub issue number! (" + repr(issue_number) + ")")

self.append((metadata, text))
metadata = {}
Expand Down Expand Up @@ -567,7 +567,7 @@ def _parse_next_filename(filename):
metadata = {"date": fields[0], "nonce": fields[-2], "section": section}

for field in fields[1:-2]:
for name in ("bpo",):
for name in ("issue",):
_, got, value = field.partition(name + "-")
if got:
metadata[name] = value.strip()
Expand All @@ -588,7 +588,7 @@ def ensure_metadata(self):
metadata, body = self[-1]
assert 'section' in metadata
for name, default in (
("bpo", "0"),
("issue", "0"),
("date", sortable_datetime()),
("nonce", nonceify(body)),
):
Expand All @@ -603,8 +603,8 @@ def _extract_next_filename(self):
metadata, body = self[-1]
metadata['section'] = sanitize_section(metadata['section'])
metadata['root'] = root
path = "{root}/Misc/NEWS.d/next/{section}/{date}.bpo-{bpo}.{nonce}.rst".format_map(metadata)
for name in "root section date bpo nonce".split():
path = "{root}/Misc/NEWS.d/next/{section}/{date}.gh-{issue}.{nonce}.rst".format_map(metadata)
for name in "root section date issue nonce".split():
del metadata[name]
return path

Expand Down Expand Up @@ -892,14 +892,14 @@ def init_tmp_with_template():
# my editor likes to strip trailing whitespace from lines.
# normally this is a good idea. but in the case of the template
# it's unhelpful.
# so, manually ensure there's a space at the end of the bpo line.
# so, manually ensure there's a space at the end of the issue line.
text = template

bpo_line = ".. bpo:"
without_space = "\n" + bpo_line + "\n"
with_space = "\n" + bpo_line + " \n"
issue_line = ".. issue:"
without_space = "\n" + issue_line + "\n"
with_space = "\n" + issue_line + " \n"
if without_space not in text:
sys.exit("Can't find BPO line to ensure there's a space on the end!")
sys.exit("Can't find Issue line to ensure there's a space on the end!")
text = text.replace(without_space, with_space)
file.write(text)

Expand Down Expand Up @@ -977,7 +977,7 @@ def release(version):
if not filenames:
print(f"No blurbs found. Setting {version} as having no changes.")
body = f"There were no new changes in version {version}.\n"
metadata = {"no changes": "True", "bpo": "0", "section": "Library", "date": date, "nonce": nonceify(body)}
metadata = {"no changes": "True", "issue": "0", "section": "Library", "date": date, "nonce": nonceify(body)}
blurbs.append((metadata, body))
else:
no_changes = None
Expand Down Expand Up @@ -1098,9 +1098,9 @@ def print(*a, sep=" "):
print("-" * len(section))
print()

bpo = metadata['bpo']
if int(bpo):
body = "bpo-" + bpo + ": " + body
issue_number = metadata['issue']
if int(issue_number):
body = "gh-" + issue_number + ": " + body
body = "- " + body
text = textwrap_body(body, subsequent_indent=' ')
print(text)
Expand Down Expand Up @@ -1220,7 +1220,7 @@ def global_sections():
blurbs = Blurbs()

accumulator = []
bpo = "0"
issue_number = "0"
serial_number = 9999
version = None
release_date = None
Expand All @@ -1235,7 +1235,7 @@ def global_sections():
def flush_blurb():
nonlocal accumulator
nonlocal serial_number
nonlocal bpo
nonlocal issue_number
nonlocal release_date
nonlocal see_also
nonlocal no_changes
Expand Down Expand Up @@ -1266,7 +1266,7 @@ def flush_blurb():
field = field[1:]
try:
int(field)
field = "bpo-" + field
field = "gh-" + field
except ValueError:
pass
fields.append(field)
Expand All @@ -1281,7 +1281,7 @@ def flush_blurb():

body = "\n".join(accumulator) + "\n"
metadata = {}
metadata["bpo"] = bpo
metadata["issue"] = issue_number
metadata["date"] = str(serial_number)
if section:
metadata["section"] = section
Expand All @@ -1305,7 +1305,7 @@ def flush_blurb():
blurbs.append((metadata, body))
blurb_count += 1

bpo = "0"
issue_number = "0"
serial_number -= 1
accumulator.clear()

Expand All @@ -1328,7 +1328,7 @@ def flush_version():
else:
# saving a million old-school blurb next files
# with serial numbers instead of dates
# e.g. Misc/NEWS.d/next/IDLE/094.bpo-25514.882pXa.rst
# e.g. Misc/NEWS.d/next/IDLE/094.gh-25514.882pXa.rst
filenames = blurbs.save_split_next()
git_add_files.extend(filenames)
released = True
Expand Down Expand Up @@ -1359,7 +1359,7 @@ def flush_version():
line = new
# 2. unusual indenting
_line = line.lstrip()
if _line.startswith(("- Issue #", "- bpo-")):
if _line.startswith(("- Issue #", "- gh-")):
line = _line
if _line == ".characters() and ignorableWhitespace() methods. Original patch by Sebastian":
line = " " + line
Expand Down Expand Up @@ -1501,54 +1501,54 @@ def flush_version():
line = line.lstrip()
if line.startswith("#"):
line = line[1:].lstrip()
parse_bpo = True
elif line.startswith("bpo-"):
line = line[4:]
parse_bpo = True
parse_issue = True
elif line.startswith("gh-"):
line = line[3:]
parse_issue = True
else:
# print(f"[[{line_number:8} no bpo]] {line}")
parse_bpo = False
if parse_bpo:
# print(f"[[{line_number:8} no gh]] {line}")
parse_issue = False
if parse_issue:
# GAAAH
if line == "17500, and https://github.com/python/pythondotorg/issues/945: Remove":
line = "Remove"
bpo = "17500"
issue = "17500"
see_also = "https://github.com/python/pythondotorg/issues/945"
else:
bpo, colon, line = line.partition(":")
issue, colon, line = line.partition(":")
line = line.lstrip()
bpo, comma, see_also = bpo.partition(",")
issue, comma, see_also = issue.partition(",")
if comma:
see_also = see_also.strip()
# if it's just an integer, add bpo- to the front
# if it's just an integer, add gh- to the front
try:
int(see_also)
see_also = "bpo-" + see_also
see_also = "gh-" + see_also
except ValueError:
pass
else:
# - Issue #21529 (CVE-2014-4616)
bpo, space_paren, see_also = bpo.partition(" (")
issue, space_paren, see_also = issue.partition(" (")
if space_paren:
see_also = see_also.rstrip(")")
else:
# - Issue #19544 and Issue #1180:
bpo, space_and, see_also = bpo.partition(" and ")
issue, space_and, see_also = issue.partition(" and ")
if not space_and:
bpo, space_and, see_also = bpo.partition(" & ")
issue, space_and, see_also = issue.partition(" & ")
if space_and:
see_also = see_also.replace("Issue #", "bpo-").strip()
see_also = see_also.replace("Issue #", "gh-").strip()
else:
# - Issue #5258/#10642: if site.py
bpo, slash, see_also = bpo.partition("/")
issue, slash, see_also = issue.partition("/")
if space_and:
see_also = see_also.replace("#", "bpo-").strip()
see_also = see_also.replace("#", "gh-").strip()
try:
int(bpo) # this will throw if it's not a legal int
int(issue) # this will throw if it's not a legal int
except ValueError:
sys.exit(f"Couldn't convert bpo number to int on line {line_number}! {bpo!r}")
sys.exit(f"Couldn't convert issue number to int on line {line_number}! {issue!r}")
if see_also == "partially":
sys.exit(f"What the hell on line {line_number}! {bpo!r}")
sys.exit(f"What the hell on line {line_number}! {issue!r}")

# 4.6.1 continuation of blurb
elif line.startswith(" "):
Expand Down
2 changes: 1 addition & 1 deletion blurb/tests/fail/bpo-.rst
Original file line number Diff line number Diff line change
@@ -1 +1 @@
bpo-12345: Fixed some problem or other.
gh-12345: Fixed some problem or other.
2 changes: 1 addition & 1 deletion blurb/tests/pass/basic.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. bpo: 0
.. issue: 0
.. date: 2017-05-02
.. nonce: xyz
.. section: Library
Expand Down
2 changes: 1 addition & 1 deletion blurb/tests/pass/no-break-long-words.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.. bpo: 0
.. date: 1234
.. issue: 0
.. nonce: xyz
.. section: Library

Expand Down
Loading
0