diff --git a/.serena/memories/scripts/changelog.md b/.serena/memories/scripts/changelog.md index 6785692d82..d8ea1b7d84 100644 --- a/.serena/memories/scripts/changelog.md +++ b/.serena/memories/scripts/changelog.md @@ -8,7 +8,7 @@ - `boom [--changes CHANGES.md --write]` — generate `### :boom: Breaking changes & Deprecations` from the closed, non-excluded milestone issues labelled `breaking change`, sorted by issue number. Each issue becomes a `#### ` block: content = body of the issue's last `## Breaking change note` comment (whole markdown, headings demoted to `#####` outside code fences; fallback = heading plus refs with a stderr warning), refs = issue link plus merged closing PRs on their own line, with `(by @author)` for `community contribution`. `--write` replaces only that subsection of the version (inserts it after the version header when missing, keeps the heading when there are no entries; idempotent). Print-only by default. Uses `gh.py comments`. - `security [--changes CHANGES.md --write]` — generate `### :lock: Security fixes` from the advisories whose `patched_versions` include the version (via `gh.py advisories --patched-version`), sorted by GHSA id. Entry: `- Fix () (PR: [#N](...))`; description = `Fix` + advisory summary, first word decapitalized unless it starts with an acronym; PRs = merged milestone PRs labelled `pr pt` whose body contains the GHSA id, comma-separated, and no PR is legal. Warns on stderr when a `pr pt` PR references an advisory with no matching `patched_versions`. `--write` replaces only that subsection, placed after `:rocket:` (or `:boom:`, or the version header when neither exists); empty entries remove the subsection; idempotent. Print-only by default. - `cross-ref [--changes CHANGES.md]` — fetch milestone PRs with `--state all` once, report merged PRs missing from the version section plus CLOSED (unmerged) warnings. PR links inside `:lock:` entries count as referenced; advisory URLs never appear here by design. -- `dev-only-bugs [--apply]` — list closed milestone bugs that never reached production, without `no changelog`. Sure: parent issue is a `Feature`/`Enhancement` of the same milestone; `--apply` adds `no changelog` to these only. Candidates (never labelled automatically): parent is an epic of the milestone, `regression` label, or the "Affected versions" / "Environment" body field names only hourly, develop, staging, PRE or this milestone (`only_unreleased_envs`; any production hint or other version keeps the bug in). Reads `body` and `parent` from one batched `gh.py issue` lookup. +- `dev-only-bugs [--apply]` — list closed milestone bugs that never reached production, without `no changelog`. Sure: parent issue is a `Feature`/`Enhancement` of the same milestone; `--apply` adds `no changelog` to these only. Candidates (never labelled automatically): parent is an epic of the milestone, `regression` label, or the "Affected versions" / "Environment" body field names only hourly, develop, staging, PRE or the milestone version itself (`only_unreleased_envs`; any production hint or other version keeps the bug in — versions compare as full semver with missing patch = 0, so for milestone 2.19.2 the released 2.19.0 keeps the bug in). Reads `body` and `parent` from one batched `gh.py issue` lookup. - `report [--changes CHANGES.md --output CHANGES-ISSUES.md]` — overwrite the anomaly report: A/B milestone mismatches, E `:boom:` entry without the label, F `:rocket:` sync, G `:boom:` sync, plus the C/D `:rocket:` gaps and the `dev-only-bugs` lists (warnings). `:boom:`/`:rocket:` rule violations are fixed by regenerating or relabelling, not by editing entries in place. ## Conventions diff --git a/.serena/memories/workflow/updating-changelog.md b/.serena/memories/workflow/updating-changelog.md index 1c233312b3..008e0fc8df 100644 --- a/.serena/memories/workflow/updating-changelog.md +++ b/.serena/memories/workflow/updating-changelog.md @@ -161,7 +161,7 @@ Generated from the advisories that declare the version in `patched_versions`; ne 2. **Fetch the milestone issues**: `python3 scripts/gh.py issues "" --exclude "release blocker,no changelog"` (closed by default; add `--state all` only to inspect open issues). `gh.py` already drops `Task` and `Rejected`; pass `--include-tasks` / `--include-rejected` only to inspect them. To find what is missing from an existing section, add `--compare CHANGES.md`. 3. **Keep out bugs that never reached production**: `python3 scripts/changelog.py dev-only-bugs ""` lists them; add `--apply` to label the sure ones `no changelog` on GitHub, then re-fetch step 2. The label puts the decision on the issue, so it survives a regeneration. - **Sure**: a bug whose parent issue is a `Feature` or `Enhancement` of the same milestone. `--apply` labels these. - - **Candidates**: a bug whose parent is an epic of the same milestone, that carries the `regression` label, or whose "Affected versions" / "Environment" field names only hourly, develop, staging, PRE or a version of this milestone. `regression` also marks regressions users hit in production, and the field says where the bug was seen, not since when it exists, so never label these yourself: show them to the user, who labels the ones they confirm. The anomaly report lists them too (section 10). + - **Candidates**: a bug whose parent is an epic of the same milestone, that carries the `regression` label, or whose "Affected versions" / "Environment" field names only hourly, develop, staging, PRE or the milestone version itself. `regression` also marks regressions users hit in production, and the field says where the bug was seen, not since when it exists, so never label these yourself: show them to the user, who labels the ones they confirm. The anomaly report lists them too (section 10). 4. **Fetch PR details when needed**: `python3 scripts/gh.py prs ` (also `--milestone`). Use it for the PR author, labels and merge state. 5. **Categorize** by Issue Type and the two labels (section 2), and **build the descriptions** (section 4). 6. **Verify PR merge status** before writing: `python3 scripts/changelog.py check-merged `. Only merged PRs go in the changelog; if a closing PR was closed unmerged, look for the PR that superseded it. diff --git a/scripts/changelog.py b/scripts/changelog.py index e09cfa1218..fab0018199 100644 --- a/scripts/changelog.py +++ b/scripts/changelog.py @@ -634,7 +634,7 @@ PROD_ENV_RE = re.compile( r"\b(?:production|pro|main|saas|design\.penpot\.app|self[- ]?hosted?)\b", re.IGNORECASE, ) -VERSION_RE = re.compile(r"\b(\d+)\.(\d+)(?:\.\d+)?") +VERSION_RE = re.compile(r"\b(\d+)\.(\d+)(?:\.(\d+))?") def version_field(body: str | None) -> str: @@ -643,12 +643,21 @@ def version_field(body: str | None) -> str: return " ".join(match.group(1).split()) if match else "" +def full_version(match: tuple[str, ...]) -> tuple[int, int, int]: + """Normalize a version regex match to (major, minor, patch).""" + major, minor, patch = match + return (int(major), int(minor), int(patch) if patch else 0) + + def only_unreleased_envs(text: str, milestone: str) -> bool: """True when the version text names unreleased environments only: - hourly, develop, staging, PRE or a version of this milestone. Any + hourly, develop, staging, PRE or exactly this milestone. Any production hint or other version number keeps the bug in the changelog.""" - current = tuple(milestone.split(".")[:2]) - versions = [m for m in VERSION_RE.findall(text)] + current_match = VERSION_RE.search(milestone) + if current_match is None: + raise ValueError(f"milestone {milestone!r} is not a semver version") + current = full_version(current_match.groups()) + versions = [full_version(m) for m in VERSION_RE.findall(text)] dev = bool(DEV_ENV_RE.search(text)) or current in versions prod = bool(PROD_ENV_RE.search(text)) or any(v != current for v in versions) return dev and not prod diff --git a/scripts/test_changelog.py b/scripts/test_changelog.py index 8eb0311c9f..fba2c541c0 100644 --- a/scripts/test_changelog.py +++ b/scripts/test_changelog.py @@ -692,6 +692,18 @@ class OnlyUnreleasedEnvsTests(unittest.TestCase): with self.subTest(text=text): self.assertFalse(self.check(text)) + def test_released_patch_of_the_same_minor_is_production(self): + # 2.19.0/2.19.1 are released versions, not this milestone (2.19.2): + # any version other than the milestone itself keeps the bug in. + for text in ["2.19.0 and later", "2.19.1", "2.19.0-RC1", "since 2.16"]: + with self.subTest(text=text): + self.assertFalse(ch.only_unreleased_envs(text, "2.19.2")) + + def test_milestone_version_itself_is_unreleased(self): + for text in ["2.19.2", "2.19.2-RC1 (develop)"]: + with self.subTest(text=text): + self.assertTrue(ch.only_unreleased_envs(text, "2.19.2")) + class FindDevOnlyBugsTests(unittest.TestCase): def test_splits_auto_and_suggested(self):