From 50335cd845a25151987bd87a75b6790b2a8da5ef Mon Sep 17 00:00:00 2001 From: Drefvelin <54400154+Drefvelin@users.noreply.github.com> Date: Fri, 25 Sep 2026 11:07:46 +0000 Subject: [PATCH] Leave pull request numbers out of patch notes. GitHub adds (#33) to a squash title. That number is not something players need to see, so it is removed from new notes and from notes already stored. Co-authored-by: Cursor --- backend/src/api/patchnotes_routes.py | 4 ++-- backend/src/api/test_patchnotes_routes.py | 9 +++++++++ backend/src/patchnotes/summarize.py | 7 +++++++ backend/src/patchnotes/test_summarize.py | 11 +++++++++++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/backend/src/api/patchnotes_routes.py b/backend/src/api/patchnotes_routes.py index 83d2baa..5bdbb72 100644 --- a/backend/src/api/patchnotes_routes.py +++ b/backend/src/api/patchnotes_routes.py @@ -61,7 +61,7 @@ from src.patchnotes.feedback import FeedbackError, interpret_feedback from src.patchnotes.folders import catalog_entries, clean_folder_name, safe_rule from src.patchnotes.safety import hidden_knowledge_warning -from src.patchnotes.summarize import signature_ok, summarize_push +from src.patchnotes.summarize import signature_ok, strip_pr_numbers, summarize_push from src.skins.auth import HEADER_STAFF_KEY, require_staff_key logger = logging.getLogger("patchnotes.routes") @@ -120,7 +120,7 @@ def _serialize(row: dict[str, Any], *, public: bool) -> dict[str, Any]: "id": str(row["id"]), "week": row["week"], "section": row["section"], - "body": row["body"], + "body": strip_pr_numbers(str(row.get("body") or "")).strip(), "created_at": _iso(row.get("created_at")), "highlight": bool(row.get("highlight")), } diff --git a/backend/src/api/test_patchnotes_routes.py b/backend/src/api/test_patchnotes_routes.py index b67f815..abc19e9 100644 --- a/backend/src/api/test_patchnotes_routes.py +++ b/backend/src/api/test_patchnotes_routes.py @@ -333,6 +333,15 @@ def test_published_weeks_need_no_auth(self, _mock_weeks) -> None: self.assertEqual(res.status_code, 200) self.assertEqual(res.json()["weeks"], ["2026-W39"]) + @mock.patch( + "src.api.patchnotes_routes.list_approved", + return_value=[_row(status="approved", body="Added evil RP sessions (#33)")], + ) + def test_published_week_hides_pull_request_numbers(self, _mock_list) -> None: + res = self.client.get("/patchnotes/weeks/2026-W39") + self.assertEqual(res.status_code, 200) + self.assertEqual(res.json()["bullets"][0]["body"], "Added evil RP sessions") + @mock.patch( "src.api.patchnotes_routes.list_approved", return_value=[ diff --git a/backend/src/patchnotes/summarize.py b/backend/src/patchnotes/summarize.py index 6ced77b..9ac95a4 100644 --- a/backend/src/patchnotes/summarize.py +++ b/backend/src/patchnotes/summarize.py @@ -83,6 +83,7 @@ _COORDS = re.compile(r"(? str: return "technical" +def strip_pr_numbers(text: str) -> str: + """Drop GitHub pull-request numbers. They are not part of the note.""" + return _PR_NUMBER.sub("", text or "") + + def player_text(text: str) -> str | None: """A line safe to store, or None when the line must not be stored at all.""" + text = strip_pr_numbers(text) if ( hidden_knowledge_warning(text) or _SECRET.search(text) diff --git a/backend/src/patchnotes/test_summarize.py b/backend/src/patchnotes/test_summarize.py index 848ee03..ee428a0 100644 --- a/backend/src/patchnotes/test_summarize.py +++ b/backend/src/patchnotes/test_summarize.py @@ -96,6 +96,17 @@ def test_withholds_lore_secrets_exploits_and_permissions(self) -> None: self.assertEqual(notes.drafts, [], message) self.assertEqual(notes.withheld, 1, message) + def test_leaves_out_pull_request_numbers(self) -> None: + notes = summarize_push( + _push("fry eggs using chicken genetics for quality (#38)") + ) + self.assertEqual(len(notes.drafts), 1) + self.assertEqual( + notes.drafts[0].body, + "Gathering: fry eggs using chicken genetics for quality", + ) + self.assertNotIn("#38", notes.drafts[0].body) + def test_strips_coordinates_and_keeps_the_fix(self) -> None: notes = summarize_push(_push("fix: Fixed a chest at 1204, 64, -880")) self.assertEqual(len(notes.drafts), 1)