diff --git a/tests/test_release_train.py b/tests/test_release_train.py index d69fc0793..17414abbd 100644 --- a/tests/test_release_train.py +++ b/tests/test_release_train.py @@ -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") diff --git a/tools/release_train.py b/tools/release_train.py index 511ccac5e..cf3219fde 100644 --- a/tools/release_train.py +++ b/tools/release_train.py @@ -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