Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
17 changes: 13 additions & 4 deletions scripts/release_notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,23 +126,32 @@ def section_of(labels):


# the trailing notes of a title that point at issues, for the people who work on the project and not for a reader of a release:
# (refs #388, #315), (closes #371), (fixes #5), (rank 2 of #388)
# (refs #388, #315), (closes #371), (fixes #5), (rank 2 of #388), and a bare (#452) that stands next to the number of the pull request
ISSUE_NOTE = re.compile(
r"\s*\((?:refs?|closes?|fix(?:es)?|rank \d+ of)\s+#\d+(?:\s*,\s*#\d+)*\)\s*$",
r"\s*\((?:(?:refs?|closes?|fix(?:es)?|rank \d+ of)\s+)?#\d+(?:\s*,\s*#\d+)*\)\s*$",
re.IGNORECASE,
)
# a commit-style prefix that carries an issue number: `fix(#412): the native bytes cache ...`, `docs(#431): many small graph batches ...`
KIND_PREFIX = re.compile(
r"^(?:fix|feat|docs?|perf|chore|ci|tests?|refactor)\(#\d+\):\s*", re.IGNORECASE
)
# a pull request that only merges a release line back into main (`Merge the 26.11.1.post3 release line into main`)
MERGE_LINE = re.compile(r"^Merge the \S+ release line into main\b", re.IGNORECASE)


def clean_title(title, number):
"""The title without a trailing (#N) of the pull request itself, which the line adds, and without trailing notes that point at issues."""
"""The title without a trailing (#N) of the pull request itself, which the line adds, without trailing notes that point at issues and without a `fix(#N):` prefix."""
text = re.sub(rf"\s*\(#{number}\)\s*$", "", title.strip())
while True:
shorter = ISSUE_NOTE.sub("", text)
if shorter == text or not shorter:
return text
break
text = shorter
bare = KIND_PREFIX.sub("", text)
if bare and bare != text:
# a lower-case word becomes a sentence start; an identifier such as find_nearest(...) stays as written
text = re.sub(r"^[a-z]+\b(?![_(.\-])", lambda m: m.group(0).capitalize(), bare)
return text


def safe_title(title):
Expand Down
18 changes: 17 additions & 1 deletion tests/test_release_notes_titles.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,24 @@ def _load():
(
"fix(#423): find_nearest(allowed_rids=[]) returns nothing (#425)",
425,
"fix(#423): find_nearest(allowed_rids=[]) returns nothing",
"find_nearest(allowed_rids=[]) returns nothing",
),
(
"fix(#412): the native bytes cache keeps no write parameters (#413)",
413,
"The native bytes cache keeps no write parameters",
),
(
"docs(#431): many small graph batches pay a fixed cost (#432)",
432,
"Many small graph batches pay a fixed cost",
),
(
"JVM: to_json_list() returns a float for every DECIMAL (#452) (#456)",
456,
"JVM: to_json_list() returns a float for every DECIMAL",
),
("fix(#5): (#6)", 6, "fix(#5):"),
("(refs #9) (#9)", 9, "(refs #9)"),
],
)
Expand Down
Loading