Skip to content

build(release): stop adding blank lines to the changelog on every backport - #4601

Merged
aignas merged 2 commits into
bazel-contrib:mainfrom
aignas:fix.aignas.changelog-blank-lines
Dec 2, 2026
Merged

aignas merged 2 commits into
bazel-contrib:mainfrom
aignas:fix.aignas.changelog-blank-lines

Conversation

@aignas

@aignas aignas commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Every backport added one blank line to CHANGELOG.md in front of the
next version, so a release with N backports ended up with N extra blank
lines. The changelog sync for 2.5.2 in #4600 shows it.

When the news of a backport were merged into an existing version block,
the match for the block stopped before the blank lines that separate it
from the next version anchor, yet the replacement appended a newline.
The blank lines were kept and one more was added on every merge.

To fix, normalize the gap after a merged block to the two blank lines
that a new version block gets. This also repairs blocks that already
have too many when they are next merged into.

The block text no longer goes through a regex replacement string, so a
backslash in the changelog or in a news entry no longer fails the merge.

  • Also removes the extra blank lines in front of the 2.4.6, 2.3.4 and
    2.1.0 blocks and the trailing whitespace in CHANGELOG.md.

…kport

When the news of a backport were merged into an existing version block,
a newline was added after the block, whilst the blank lines that
separate it from the next version were kept. A release with N backports
ended up with N extra blank lines.

Normalize the separator to the two blank lines that a new version block
gets, which also fixes the blocks that already have too many.

The block is no longer passed through a regex replacement string, so a
backslash in the changelog or in a news entry does not fail the merge.
The release tooling used to add a blank line for every backport, which
left up to five blank lines between the 2.4.6, 2.3.4 and 2.1.0 blocks
and the versions before them.
@aignas
aignas requested a review from rickeylev as a code owner December 1, 2026 14:09
@aignas

aignas commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator Author

AI disclosure: this PR was prepared by an AI agent (Claude Code) on behalf of the author. The agent replies to review comments and pushes fixes; the author supervises and reviews the changes.

This is an agent-generated comment unreviewed by the user.

@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The changelog merge code now uses a shared separator and normalizes spacing after existing-version merges. Regression tests cover repeated updates, entries with backslashes, and excess blank lines. The changelog also has extra blank lines and trailing whitespace removed.

Changes: Changelog merge formatting

Layer / File(s) Summary
Merge spacing and regression coverage
dev/release/changelog_news.py, tests/tools/private/release/changelog_news_test.py, CHANGELOG.md
Existing-version merges normalize spacing before following content, and new-version insertion uses the shared separator. Tests cover repeated merges, entries with backslashes, and excess blank lines. The changelog has extra blank lines and trailing whitespace removed.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: Minimal · up to 2b6bd

This fixes the extra blank lines added to the changelog on every backport and avoids failures when entries contain backslashes. No remaining merge-blocking risk was identified. The failing CI build is not attributed to this change, but confirm it before merging.

Security architecture risk: Minimal · up to 2b6bd

The change fixes changelog spacing and preserves literal backslashes without adding a public interface or changing where release files are written.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the release tooling stops adding blank lines to CHANGELOG.md on each backport. The changeset matches this. The changelog normalizes the gap after a merged block, chang…
Description check Passed The description explains the cause of the bug, the fix that normalizes blank lines after a merged block, and the removal of extra blank lines and trailing whitespace in CHANGELOG.md. It also covers th…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: the release tooling stops adding blank lines to CHANGELOG.md on each backport. The changeset matches this. The changelog normalizes the gap after a merged block, changes the merge code in dev/release/changelog_news.py, and adds regression tests for repeated merges.

Full details: Description check

Explanation

The description explains the cause of the bug, the fix that normalizes blank lines after a merged block, and the removal of extra blank lines and trailing whitespace in CHANGELOG.md. It also covers the backslash fix that removes the regex replacement string. All of this matches the changeset.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
Fix failing CI checks

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between f536710 and 2b6bdc0.

Files selected for processing: 3

  • CHANGELOG.md
  • dev/release/changelog_news.py
  • tests/tools/private/release/changelog_news_test.py

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@aignas
aignas merged commit 9cd10fe into bazel-contrib:main Dec 2, 2026
27 of 28 checks passed
@aignas
aignas deleted the fix.aignas.changelog-blank-lines branch December 2, 2026 10:36
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