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
4 changes: 2 additions & 2 deletions backend/src/api/patchnotes_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")),
}
Expand Down
9 changes: 9 additions & 0 deletions backend/src/api/test_patchnotes_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[
Expand Down
7 changes: 7 additions & 0 deletions backend/src/patchnotes/summarize.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
_COORDS = re.compile(r"(?<![\w.])-?\d{3,6}\s*,\s*-?\d{1,4}\s*,\s*-?\d{3,6}(?![\w.])")
_XYZ = re.compile(r"(?<![A-Za-z0-9])[xyz]\s*[:=]\s*-?\d{1,6}", re.IGNORECASE)
_WORD = re.compile(r"[A-Za-z]{2,}")
_PR_NUMBER = re.compile(r"\s*\(#\d+\)")


@dataclass(frozen=True)
Expand Down Expand Up @@ -208,8 +209,14 @@ def _section(kind: str, text: str) -> 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)
Expand Down
11 changes: 11 additions & 0 deletions backend/src/patchnotes/test_summarize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down