release_train: name a feature split over several pull requests once in the title; no leading Fix
Today's main would have been titled "Controllers, controllers, controllers and 17 more changes". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -81,6 +81,14 @@ class ReleaseTrainTests(unittest.TestCase):
|
||||
self.assertTrue(title.endswith("more fixes"), title)
|
||||
self.assertLess(len(title), 100)
|
||||
|
||||
def test_a_feature_split_over_several_pull_requests_is_named_once(self):
|
||||
prs = [pr(1, "Controllers: rumble", labels=["feature"]), pr(2, "Controllers: menus", labels=["feature"]),
|
||||
pr(3, "Maces: smash attacks"), pr(4, "Fix stuck keys when opening Options")]
|
||||
title, _ = train.notes("game", "v2026.10.15", prs, [])
|
||||
self.assertEqual(title, "Horizon 2026.10.15: Controllers, stuck keys when opening Options, maces")
|
||||
self.assertEqual(train.summary([], [pr(n, f"Change number {n} with a fairly long title") for n in range(4)]),
|
||||
"Change number 3 with a fairly long title and 3 more fixes")
|
||||
|
||||
def test_launcher_notes(self):
|
||||
title, body = train.notes("launcher", "launcher-v0.2.0", [pr(3, "Launcher: say the self-update succeeded")], [])
|
||||
self.assertEqual(title, "Horizon launcher 0.2.0")
|
||||
|
||||
@@ -165,12 +165,17 @@ def decision(kind, prs, last_published, now, paused=False, force=False):
|
||||
|
||||
def clause(title):
|
||||
"""The start of a pull request title, for a release's name: "Nether portals: vanilla timing" -> "Nether portals"."""
|
||||
title = re.sub(r"^(?:fix|fixes|fixed)\s+(?:the\s+)?", "", title.strip(), flags=re.I)
|
||||
return re.split(r"[:;(]| — | - ", title, maxsplit=1)[0].strip().rstrip(".")
|
||||
|
||||
|
||||
def summary(new, fixed, limit=72):
|
||||
"""A short name for the release, from its pull request titles, features first."""
|
||||
titles = [clause(pr["title"]) for pr in new[::-1] + fixed[::-1]]
|
||||
titles = []
|
||||
for pr in new[::-1] + fixed[::-1]: # several pull requests of one feature ("Controllers: ...") name it once
|
||||
title = clause(pr["title"])
|
||||
if title.lower() not in (t.lower() for t in titles):
|
||||
titles.append(title)
|
||||
shown, text = [], ""
|
||||
for title in titles:
|
||||
title = title if not shown or not title[1:2].islower() else title[0].lower() + title[1:]
|
||||
@@ -181,7 +186,8 @@ def summary(new, fixed, limit=72):
|
||||
text = candidate
|
||||
rest = len(titles) - len(shown)
|
||||
if rest:
|
||||
text += f" and {rest} more {'changes' if new else 'fixes'}"
|
||||
noun = ("change" if new else "fix") + ("" if rest == 1 else "es" if not new else "s")
|
||||
text += f" and {rest} more {noun}"
|
||||
return text
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user