Skip to content

fix(release): skip comments and fences in changelog sections - #1335

Open
vchamarthi wants to merge 3 commits into
intel:mainfrom
vchamarthi:issue-1290-release-respect-comments-and-fences
Open

vchamarthi wants to merge 3 commits into
intel:mainfrom
vchamarthi:issue-1290-release-respect-comments-and-fences

Conversation

@vchamarthi

@vchamarthi vchamarthi commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #1290. check_release.py accepted a ## [X] section whose only bullet sat inside a multiline <!-- --> comment, and --notes stopped at a ## heading inside a fenced example. I made both follow the Markdown the maintainer sees.

Changes

  • release_notes uses _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.
  • New _has_entry looks 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).
  • Tests and a Fixed fragment in changelog.d/.
  • docs/releasing.md says the check ignores comments and fences.
  • Inline code spans (including longer delimiters and multiline spans) are ignored when looking for <!--, 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.py changes. 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.py passes (71 tests), and python -m ruff check on both changed .py files 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.

  • I chose Bullets inside fenced code blocks do not count as entries over Ignoring only HTML comments for the entry check: The issue asks the check to respect fences, and a fenced example is not a release entry. Is that the behaviour you want?
  • I chose Line scan with fence state in release_notes over 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

  • Tests added/updated and pytest passes
  • ruff, mypy, and schema checks pass
  • Docs updated (or N/A) — see the docs-drift checklist in CONTRIBUTING.md
  • Self-reviewed per "Before opening a PR" in AGENTS.md
  • Each new raise/exit and test names the doc, contract or issue it traces to
  • No ad-hoc run artifacts committed
  • New files carry the SPDX license header (or are exempt in .github/.licenserc.yaml)
Checklist evidence
  • Tests added/updated and pytest passes: 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 change
  • ruff, 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 base
  • Docs updated (or N/A): updated: dokimi/docs/releasing.md
  • Self-reviewed per "Before opening a PR" in AGENTS.md: nothing left open; mutation of changed lines ran
  • Each new raise/exit and test names the doc, contract or issue it traces to: every new error path and test names a doc, contract or issue
  • No ad-hoc run artifacts committed: 1 added file(s), none a run's output
  • New files carry the SPDX license header (or are exempt in .github/.licenserc.yaml): no new source file

Fixes #1290.

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>
@vchamarthi
vchamarthi requested a review from a team as a code owner November 27, 2026 02:51
Copilot AI balanced review requested due to automatic review settings November 27, 2026 02:51
Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
Comment thread dokimi/scripts/check_release.py Fixed
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.14%. Comparing base (733c9b5) to head (5ad161f).
⚠️ Report is 7 commits behind head on main.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

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     

see 7 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
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

Comment thread dokimi/scripts/check_release.py Resolved
Comment thread dokimi/scripts/check_release.py Resolved
Comment thread dokimi/scripts/check_release.py Resolved
Comment thread dokimi/scripts/check_release.py Resolved
@exai-bot

exai-bot commented Nov 27, 2026 •

Copy link
Copy Markdown

🔍 OpenCodeReview found 3 issue(s) in this PR.

CI at `861d93c`: 2 failing, 18 passing, 4 skipped

Not fully read: log of Test Linux Wheels Python 3.14: longer than 8000000 bytes, only the start was read

The Python 3.14 test job was interrupted by a runner shutdown, rather than a reported test failure. The wheel-test failure cannot be attributed from the available truncated log; no failure diagnostic links it to the release-check changes. Other checks passed or were skipped, and local lint and type checking passed.

Check Status Assessment
Test Linux Wheels Python 3.14 failing at step Install the wheel and run ci/test.py Cause unclear. The available log is truncated (over 8 MB) and ends during passing tests around 91%, without an assertion failure, traceback, or termination diagnostic. Reading the diff and available logs does not establish whether this change caused the failure.
Tests (py3.14) failing at step Run tests Infrastructure or flaky. The runner received a shutdown signal and canceled the operation near 99% completion. The log reports an execution interruption, not a test assertion failure attributable to the changed release checker.

By label: 3 should fix

Label Location Finding
should fix check_release.py:106 Preserve literal comment markers in indented code.
should fix check_release.py:34 Stop code-span matching at ordered-list boundaries too.
should fix check_release.py:100 Recognize fences opened on a list-item line.
Review details
  • Commit reviewed: 861d93c against merge base 24984bd
  • Coverage: 4 files in 1 groups
  • Engine: OpenCodeReview v1.13.5-exai.4.8f73eada, us.openai.gpt-6.1-sol
  • Usage: 315k tokens (203k from cache), 2m35s
  • Tool calls: 18 (9 file_read, 4 pr_threads, 2 code_comment, 2 local_check_results, 1 linked_items)
  • Release checks for comments and code fences, tests, and documentation: 4 files

Comment thread dokimi/scripts/check_release.py Resolved
Comment thread dokimi/scripts/check_release.py Resolved
Comment thread dokimi/scripts/check_release.py Resolved
Comment thread dokimi/scripts/check_release.py Resolved
Comment thread dokimi/scripts/check_release.py Resolved
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>
@vchamarthi

Copy link
Copy Markdown
Contributor Author

@github-advanced-security, this is ready for another look: 1 commit on issue-1290-release-respect-comments-and-fences (5ad161f..861d93c) answers your thread.

Changes:

  • A <!-- in a multiline code span no longer hides the next release heading.
  • Backticks inside a comment no longer hide its -->.
  • An escaped \<!-- opens no comment.
  • A comment opened on the section heading hides the entries under it.
  • A code span no longer runs past a heading or into a following HTML comment block.
  • A code span no longer runs past a list item.

PR description updated:

  • Inline code spans (including longer delimiters and multiline spans) are ignored when looking for <!--, 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.

Threads and comments:

  • I answered each one in its thread: 11 fixed.

What I checked on the new commit:

  • One thread I marked fixed has no test of its own; the reply there says what changed.
  • All 3 new tests fail before the fix and pass after it.
  • The full test suite passes with main merged in (30,652 tests), apart from 1 failure main has too.
What each test shows
  • The new scanner tests: fails before, passes after.
  • The new scanner tests: fails before, passes after.
  • The new scanner tests: fails before, passes after.

_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)")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug · should fix
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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug · should fix
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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug · should fix
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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

release: respect comments and fences in changelog sections

5 participants