Repository navigation
fix(release): skip comments and fences in changelog sections - #1335
vchamarthi wants to merge 3 commits into
Conversation
check_release.py counted a bullet inside an HTML comment as a release entry, and --notes cut the section at a heading inside a fenced block. Scan the changelog line by line with fence state, and look for entries outside comments and fences. Fixes intel#1290 Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1335 +/- ##
=======================================
Coverage 96.14% 96.14%
=======================================
Files 498 499 +1
Lines 66014 66069 +55
Branches 11462 11470 +8
=======================================
+ Hits 63468 63525 +57
+ Misses 1573 1570 -3
- Partials 973 974 +1 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
4 open issues
_CODE_SPANonly matches inline code spans whose contents contain no backticks. Valid Markdown… · New_CODE_SPANonly matches inline code spans whose contents contain no backticks. Valid Markdown… · New The behavior \"ignore<!--inside inline code spans\" is tested for simple single-backtick spans,… · New This uses a backslash for line continuation inside a multi-clause conditional, which is easy to… · New
What changed in this PR
Updates the release-check logic to treat CHANGELOG.md like Markdown renderers do by ignoring headings/bullets inside HTML comments and fenced code blocks when extracting release notes and validating entries (fixes #1290).
Changes:
- Add fence/comment visibility tracking and update
release_notes()to ignore section terminators inside fences/comments. - Add
_has_entry()to only count bullets that are visible (outside fences/comments) for release validation. - Add targeted tests plus small doc/changelog updates describing the new behavior.
| File | Description |
|---|---|
| dokimi/scripts/check_release.py | Implements comment/fence-aware parsing for notes extraction and bullet detection. |
| dokimi/tests/test_check_release.py | Adds regression coverage for commented/fenced headings and bullets in changelog sections. |
| dokimi/docs/releasing.md | Documents that the release check ignores comments and fenced code blocks. |
| dokimi/changelog.d/20261126_160000_release-check-comments-fences.md | Records the fix in the changelog fragments. |
Review effort: Lite
|
🔍 OpenCodeReview found 3 issue(s) in this PR. CI at `861d93c`: 2 failing, 18 passing, 4 skippedNot fully read: log of Test Linux Wheels Python 3.14: longer than 8000000 bytes, only the start was read
By label: 3 should fix
Review details
|
Replace the line-local regex masking in check_release.py with one scan that handles multiline and longer-delimiter code spans, keeps backticks inside comments literal, ignores escaped comment openers and keeps the comment state of a section heading when checking its entries. This also removes the _COMMENT regex CodeQL flagged. Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
|
@github-advanced-security, this is ready for another look: 1 commit on Changes:
PR description updated:
Threads and comments:
What I checked on the new commit:
What each test shows
|
| _TICKS = re.compile(r"`+") | ||
| _HEADING = re.compile(r"^ {0,3}#{1,6}(?:\s|$)") | ||
| # A heading, a list item or an HTML comment at the start of a line ends the paragraph a code span lives in. | ||
| _BLOCK = re.compile(r"^(?: {0,3}(?:#{1,6}(?:\s|$)|<!--)|\s*[-*+] \S)") |
There was a problem hiding this comment.
Stop code-span matching at ordered-list boundaries too.
Trigger: a release body of Example literal\n1. <!-- draft \n - Hidden entry\n -->.
Impact: a section with no visible release bullet passes validation.
Evidence: _BLOCK omits ordered markers, so _closes pairs the paragraph's backtick with the backtick inside the next list item's HTML comment. _inline consequently skips the real comment opener, and _entries counts - Hidden entry. In Markdown, 1. interrupts the preceding paragraph and the list item contains an HTML comment block, not a cross-paragraph code span. Recognize ordered-list interruptions and add a regression through problems().
Workaround: insert a blank line before 1..
Should fix: A run shows it; it was not judged to be met in ordinary use.
Shown by running: exit 1 (at the head) · exit 1 (at the merge base, which cannot run it) · exit 0 (at the head with the fix)
python scripts/proof_c2.py
What the proof does: Checks that a bullet inside an HTML comment opened on an ordered list item is not counted as a release entry.
The problem shows as the output ORDERED_LIST_SPAN_LEAK.
dokimi/scripts/proof_c2.py
import sys
sys.path.insert(0, 'scripts')
import check_release as c
text = "## [0.2.0]\n\nExample `literal\n1. <!- - draft `\n - Hidden entry\n -->\n"
if c._section_has_entry(text, '0.2.0'):
print('ORDERED_LIST_SPAN_LEAK hidden entry counted')
sys.exit(1)ORDERED_LIST_SPAN_LEAK hidden entry counted
| and not line.strip().strip(opener[0])): | ||
| opener = "" | ||
| continue | ||
| fence = None if in_comment or span else _FENCE.match(line) |
There was a problem hiding this comment.
Recognize fences opened on a list-item line. Trigger: release_notes("## [0.2.0]\n\n- ```markdown\n example\n ```\n\n- Real entry.\n\n## [0.1.0]\n- Old entry.\n", "0.2.0"). Impact: the emitted notes include the older release despite the example's fence being closed. Evidence: - ```markdown opens a valid Markdown fence within a list item, but _FENCE.match misses it; _closes also rejects its closing marker as a paragraph boundary. The subsequent ```` is therefore treated as a new opener, hiding the real next-version boundary. The opening list line still satisfies_ENTRY`, so validation permits these incorrect notes. Handle list-container prefixes/indentation when tracking fences and add an extraction regression. Workaround: put the fenced example outside the list item.
Should fix: A run shows it; it was not judged to be met in ordinary use.
Shown by running: exit 1 (at the head) · exit 0 (at the merge base) · exit 0 (at the head with the fix)
python scripts/proof_c3.py
What the proof does: Calls release_notes on a section with a fence opened on a list-item line and checks the notes do not include the next version.
The problem shows as the output LIST_FENCE_LEAK.
dokimi/scripts/proof_c3.py
import sys
sys.path.insert(0, 'scripts')
import check_release as c
text = "## [0.2.0]\n\n- ```markdown\n example\n ```\n\n- Real entry.\n\n## [0.1.0]\n- Old entry.\n"
notes = c.release_notes(text, '0.2.0')
if notes is None or 'Old entry' in notes:
print('LIST_FENCE_LEAK', repr(notes))
sys.exit(1)LIST_FENCE_LEAK '- ```markdown\n example\n ```\n\n- Real entry.\n\n## [0.1.0]\n- Old entry.'
| scanned.append((False, "")) | ||
| continue | ||
| starts_visible = not in_comment | ||
| text, in_comment, span = _inline(lines, row, in_comment, span) |
There was a problem hiding this comment.
Preserve literal comment markers in indented code.
Trigger: text = "## [0.2.0]\n\n <!- - literal example\n\n- Real entry.\n\n## [0.1.0]\n- Old entry.\n".
Impact: problems() rejects the visible real entry, and release_notes(text, "0.2.0") includes the older release.
Evidence: the four-space code line is not a fence, so this call passes it to _inline, which sets persistent in_comment=True at the literal <!- -; subsequent bullets and headings become invisible. The new indented-code test covers only backticks, not this comment-state leak.
Fix: Handle indented code before inline comment parsing and add acceptance/extraction regressions.
Workaround: use a fenced example.
Should fix: A run shows it; it was not judged to be met in ordinary use.
Shown by running: exit 1 (at the head) · exit 1 (at the merge base, which cannot run it) · exit 0 (at the head with the fix)
python scripts/proof_c1.py
What the proof does: Calls release_notes and _section_has_entry on a changelog whose section has an indented literal comment opener, and checks the notes stop at the next version and the entry is seen.
The problem shows as the output INDENTED_COMMENT_LEAK.
dokimi/scripts/proof_c1.py
import sys
sys.path.insert(0, 'scripts')
import check_release as c
text = "## [0.2.0]\n\n <!- - literal example\n\n- Real entry.\n\n## [0.1.0]\n- Old entry.\n"
notes = c.release_notes(text, '0.2.0')
ok = notes is not None and 'Old entry' not in notes and c._section_has_entry(text, '0.2.0')
if not ok:
print('INDENTED_COMMENT_LEAK', repr(notes), c._section_has_entry(text, '0.2.0'))
sys.exit(1)INDENTED_COMMENT_LEAK ' <!- - literal example\n\n- Real entry.\n\n## [0.1.0]\n- Old entry.' False



Summary
Fixes #1290.
check_release.pyaccepted a## [X]section whose only bullet sat inside a multiline<!-- -->comment, and--notesstopped at a##heading inside a fenced example. I made both follow the Markdown the maintainer sees.Changes
release_notesuses_visible, which tracks HTML comments and fenced blocks together (a fence marker in a comment and a comment marker in a fence mean nothing) (backtick or tilde, a closing fence at least as long as the opener), so headings,<a id=anchors and version headings inside a fence are ignored._has_entrylooks for a bullet only on lines outside fences and comments, after removing comments on the line itself (an unclosed one runs to the end of the line).Fixedfragment inchangelog.d/.docs/releasing.mdsays the check ignores comments and fences.<!--, backticks inside a comment are literal, an escaped\<!--opens no comment, a comment opened on a section heading hides the entries under it, a backtick fence cannot have a backtick in its info string, and the notes keep the first line's indentation instead of stripping it.Risk
Only
scripts/check_release.pychanges. The notes text itself is returned as before; an unclosed fence now runs to the end of the file, so a stray fence makes the release check fail rather than pass.Testing
python -m pytest -q -p no:cacheprovider tests/test_check_release.py tests/test_growth_ratchet.pypasses (71 tests), andpython -m ruff checkon both changed.pyfiles is clean. New tests cover comments (closed, unclosed, several), backtick and tilde fences, a longer opening fence, an unclosed fence and a version heading inside a fence. Every new test cites #1290 in its docstring. Two tests cover a version heading inside a comment and a fence marker inside a comment. Three more tests cover a comment opener in an inline code span, an indented code example and a triple-backtick inline span.Open questions
A bullet inside a fenced example does not count as an entry, since the issue asks to respect fences; say if you would rather only comments were ignored there.
release_notesover Masking the whole changelog and slicing the original: Smallest change and keeps the notes text untouched. Is that the behaviour you want?Revert
Revert the commit; nothing is stored.
Checklist
pytestpassesruff,mypy, and schema checks passAGENTS.mdraise/exit and test names the doc, contract or issue it traces to.github/.licenserc.yaml)Checklist evidence
pytestpasses: 1 test file(s) changed; suite: 30451 passed; 1 failing test(s) fail on the base branch too: tests/test_repo_compare_interval.py::test_the_row_p_places_zero_where_large_deltas_round_p_at_zero_apart; 7 of 7 proof(s) fail before the changeruff,mypy, and schema checks pass: passed: ci.yml:static / ruff check, ci.yml:typecheck / mypy, ci.yml:static / schema-check, ci.yml:static / schema_compat vs the PR basedokimi/docs/releasing.mdAGENTS.md: nothing left open; mutation of changed lines ranraise/exit and test names the doc, contract or issue it traces to: every new error path and test names a doc, contract or issue.github/.licenserc.yaml): no new source fileFixes #1290.