Strip changelog version header from GitHub release notes#965
Conversation
The extract_changelog_section was including the ## [vX.Y.Z] header line in the release notes body, causing it to render redundantly since GitHub releases already display a separate title. Now skips the header line and returns only the section content. Co-Authored-By: Claude Opus 4.6 <[email protected]>
WalkthroughModified the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is ON, but it could not run because Privacy Mode (Legacy) is turned on. To enable Bugbot Autofix, switch your privacy mode in the Cursor dashboard.
| end_index = ((start_index + 1)...lines.length).find { |idx| lines[idx].start_with?("## [") } || lines.length | ||
| lines[start_index...end_index].join.rstrip | ||
| # Skip the version header line itself — GitHub releases display the title separately. | ||
| lines[(start_index + 1)...end_index].join.strip |
There was a problem hiding this comment.
Empty changelog section returns truthy empty string
Low Severity
extract_changelog_section can now return "" when a version header exists but has no content below it (e.g., only blank lines before the next section). Previously, it always returned a non-empty string (including the header) when a match was found. All callers use falsy checks like unless notes or return if section, and in Ruby "" is truthy, so an empty string passes these guards. This could result in creating a GitHub release with an empty body or suppressing the "no changelog content found" warning.
Additional Locations (2)
Review: Strip changelog version header from GitHub release notesOverall: LGTM with a minor note. The change is correct and focused. Before, extract_changelog_section included the version header line (e.g. Behavioral observation — rstrip to strip The switch from rstrip to strip is appropriate here. After removing the header line, the next line in the section is typically a blank newline, so strip removes that leading blank line from the notes body. Without it, the release notes would start with a blank line. Worth noting that extract_changelog_section is also used by expected_bump_type_from_changelog_section (version-policy check) and several nil-presence checks — none of those callers are sensitive to leading whitespace, so no regression there. Missing test coverage (pre-existing gap) extract_changelog_section has no RSpec coverage. Given this function now does slightly more nuanced work (skipping a line, applying strip), a unit test would help prevent regressions. Not a blocker since the gap is pre-existing, but worth a follow-up. Empty-section edge case (pre-existing) If a CHANGELOG version section has only a header and no content, strip returns an empty string. Ruby treats an empty string as truthy, so the nil-guard in prepare_github_release_context would pass and create a GitHub release with empty notes. Unrelated to this PR but worth keeping in mind. |
| end_index = ((start_index + 1)...lines.length).find { |idx| lines[idx].start_with?("## [") } || lines.length | ||
| lines[start_index...end_index].join.rstrip | ||
| # Skip the version header line itself — GitHub releases display the title separately. | ||
| lines[(start_index + 1)...end_index].join.strip |
There was a problem hiding this comment.
The strip here is correct — after skipping the header line the next line is typically a blank \n, so stripping leading whitespace prevents the notes from starting with an empty line in GitHub releases. Just be aware that this is a slight behavioral change from the old rstrip for the other callers of this function (version-policy check, nil-presence guards), though none of them are sensitive to leading whitespace.
Greptile SummaryThis PR fixes a cosmetic duplication in GitHub release notes:
Confidence Score: 5/5
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["extract_changelog_section(changelog_path, npm_version)"] --> B["Read CHANGELOG.md lines"]
B --> C{"Find start_index\nmatching ## [vX.Y.Z]"}
C -- "Not found" --> D["return nil"]
C -- "Found" --> E["Find end_index\n(next ## [ header or EOF)"]
E --> F["lines[start_index+1...end_index].join.strip\n(skip header line, strip leading/trailing whitespace)"]
F --> G["Return section content\n(no version header)"]
G --> H["prepare_github_release_context"]
H --> I{"notes present?"}
I -- "nil" --> J["abort with error"]
I -- "content" --> K["Build release_context hash\ntag, title, notes, prerelease"]
K --> L["publish_or_update_github_release"]
L --> M["Write notes to Tempfile"]
M --> N{"Release exists\non GitHub?"}
N -- "Yes" --> O["gh release edit\n--notes-file tmp.path"]
N -- "No" --> P["gh release create\n--notes-file tmp.path"]
Last reviewed commit: c643c56 |
### Summary Adds the v9.7.0 changelog section with release notes for all user-visible changes since v9.6.1: - **Added**: rspack v2 support (PR #975) - **Fixed**: Config exporter path traversal and annotation format validation (PR #914) - **Fixed**: `webpack-subresource-integrity` v5 named export handling (PR #978, fixes #972) Version diff links at the bottom of the file are updated accordingly. ### Pull Request checklist - [x] ~Add/update test to cover these changes~ - [x] ~Update documentation~ - [x] Update CHANGELOG file ### Other Information Non-user-visible PRs (#920, #965, #970, #971, #977, #979, #981, #982) were intentionally excluded per changelog policy. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Documentation-only change updating `CHANGELOG.md`; no runtime code or dependency changes are introduced in this PR. > > **Overview** > Adds a new `v9.7.0` section to `CHANGELOG.md` documenting user-visible changes (rspack v2 support and two fixes around config export security/validation and `webpack-subresource-integrity` v5 exports). > > Updates the compare links at the bottom so `[Unreleased]` now compares from `v9.7.0`, and adds the new `[v9.7.0]` tag link. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 8942a43. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added rspack v2 support * **Bug Fixes** * Improved security and validation handling <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 4.6 <[email protected]>
### Summary Adds the v9.7.0 changelog section with release notes for all user-visible changes since v9.6.1: - **Added**: rspack v2 support (PR #975) - **Fixed**: Config exporter path traversal and annotation format validation (PR #914) - **Fixed**: `webpack-subresource-integrity` v5 named export handling (PR #978, fixes #972) Version diff links at the bottom of the file are updated accordingly. ### Pull Request checklist - [x] ~Add/update test to cover these changes~ - [x] ~Update documentation~ - [x] Update CHANGELOG file ### Other Information Non-user-visible PRs (#920, #965, #970, #971, #977, #979, #981, #982) were intentionally excluded per changelog policy. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Documentation-only change updating `CHANGELOG.md`; no runtime code or dependency changes are introduced in this PR. > > **Overview** > Adds a new `v9.7.0` section to `CHANGELOG.md` documenting user-visible changes (rspack v2 support and two fixes around config export security/validation and `webpack-subresource-integrity` v5 exports). > > Updates the compare links at the bottom so `[Unreleased]` now compares from `v9.7.0`, and adds the new `[v9.7.0]` tag link. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 8942a43. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added rspack v2 support * **Bug Fixes** * Improved security and validation handling <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 4.6 <[email protected]>


Summary
extract_changelog_sectionwas including the## [vX.Y.Z] - Dateheader line in the notes, causing it to render redundantly since GitHub releases already display a separate title (v9.6.1). Now skips the header line and returns only the section content.Test plan
bundle exec rubocop rakelib/release.rakepassesrake "sync_github_release[9.6.1,true]"dry runrake "sync_github_release[9.6.1]"🤖 Generated with Claude Code
Note
Low Risk
Small, localized change to release-note formatting; minimal functional impact outside GitHub release text output.
Overview
Updates
extract_changelog_sectioninrakelib/release.raketo exclude the version header line (## [vX.Y.Z] ...) from the GitHub release notes body, returning only the section content.This prevents duplicate version titles in GitHub releases and slightly changes whitespace trimming by using
stripon the extracted content.Written by Cursor Bugbot for commit c643c56. Configure here.
Summary by CodeRabbit