Skip to content

Strip changelog version header from GitHub release notes#965

Merged
justin808 merged 1 commit intomainfrom
jg/965-strip-changelog-header-from-gh-release
Mar 8, 2026
Merged

Strip changelog version header from GitHub release notes#965
justin808 merged 1 commit intomainfrom
jg/965-strip-changelog-header-from-gh-release

Conversation

@justin808
Copy link
Copy Markdown
Member

@justin808 justin808 commented Mar 8, 2026

Summary

  • Removed duplicate version header from GitHub release notes body. extract_changelog_section was including the ## [vX.Y.Z] - Date header 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.rake passes
  • Verify with rake "sync_github_release[9.6.1,true]" dry run
  • Re-sync v9.6.1 release after merging: rake "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_section in rakelib/release.rake to 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 strip on the extracted content.

Written by Cursor Bugbot for commit c643c56. Configure here.

Summary by CodeRabbit

  • Chores
    • Improved changelog extraction during release process to properly skip version headers and handle whitespace trimming.

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]>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 8, 2026

Walkthrough

Modified the extract_changelog_section method in the release rake file to skip the version header line when extracting changelog content. Changed whitespace trimming from rstrip to strip for more comprehensive cleanup of surrounding whitespace.

Changes

Cohort / File(s) Summary
Changelog Extraction Logic
rakelib/release.rake
Updated extract_changelog_section to exclude the header line from the extracted section and improved whitespace handling by switching from rstrip to strip.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A snippet of code, so small yet so neat,
The header line skipped, the slice now complete,
With strip in its place, the whitespace takes flight,
The changelog extracted, precisely just right!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: removing the version header from changelog sections used in GitHub release notes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch jg/965-strip-changelog-header-from-gh-release

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

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.

Comment thread rakelib/release.rake
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
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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)

Fix in Cursor Fix in Web

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Mar 8, 2026

Review: Strip changelog version header from GitHub release notes

Overall: LGTM with a minor note.

The change is correct and focused. Before, extract_changelog_section included the version header line (e.g. ## [v9.6.1] - March 8, 2026) in the returned string, causing it to appear as body text in GitHub releases alongside the already-displayed tag title. Skipping it is the right fix.

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.

Comment thread rakelib/release.rake
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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Mar 8, 2026

Greptile Summary

This PR fixes a cosmetic duplication in GitHub release notes: extract_changelog_section previously included the ## [vX.Y.Z] - Date header in the returned string, causing it to render redundantly alongside GitHub's own release title. The fix is a two-line change — start slicing from start_index + 1 to skip the header, and use .strip to also remove the leading blank line that typically follows the header in the CHANGELOG.

  • Skips version header: lines[(start_index + 1)...end_index] instead of lines[start_index...end_index], removing the ## [vX.Y.Z] line from release body content.
  • .strip usage: Removes both leading and trailing whitespace, which is necessary because the first content line is typically preceded by a blank line after the header.
  • No test coverage exists for extract_changelog_section, but this is a pre-existing gap and the logic is straightforward to verify manually via the suggested dry-run task.

Confidence Score: 5/5

  • This PR is safe to merge — it is a minimal, focused fix with no risk of breakage.
  • The change is two lines: shifting the slice start by one index to skip the version header, and using .strip to clean up the leading blank line that now appears at the start of the content. Both changes are correct, the logic is easy to verify by inspection against the CHANGELOG format, and the stated dry-run test plan provides a practical sanity check before the live re-sync.
  • No files require special attention

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"]
Loading

Last reviewed commit: c643c56

@justin808 justin808 merged commit 8803964 into main Mar 8, 2026
9 checks passed
@justin808 justin808 deleted the jg/965-strip-changelog-header-from-gh-release branch March 8, 2026 23:42
justin808 added a commit that referenced this pull request Mar 17, 2026
### 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]>
justin808 added a commit that referenced this pull request Mar 18, 2026
### 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]>
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.

1 participant