Skip to content

Improve default changelog new lines handling - #2118

Merged
bluwy merged 2 commits into
mainfrom
improve-changelog-new-line
Jun 24, 2026
Merged

bluwy merged 2 commits into
mainfrom
improve-changelog-new-line

Conversation

@bluwy

@bluwy bluwy commented Jun 24, 2026

Copy link
Copy Markdown
Member

fixes #748

Uses a slightly sophisticated handling when joining release lines to ensure there's a minimum of one new line and maximum of two new lines between the release lines.

One new line means there's only one \n, so there's no spacing in between. Two new lines is \n\n so there's a spacing in between.

Also ensure that headings such as ### Major changes and ## 1.0.0 are followed with \n\n. This should look more proper to how most formatters format it.

Context and thought process

I did this change in the getChangelogEntry side instead of the changelog generator side (e.g. changelog-github), because it's possible that some generators prefer lines to be followed together or with spacing in between. For example:

changelog-git:

- change one
- change two

changelog-github:

- [abc123] change one (#1234)

- [def456] change two (#5678)

But at the same time, we limit to a maximum of 2 new lines in between (one spacing) because there's not a lot of reason in practice to want more than that. So getChangelogEntry has a little opinion on that, but in return generators don't need to think too deeply on how new lines would be combined in the changelog. Maybe we want to discuss this magic a bit.

@changeset-bot

changeset-bot Bot commented Jun 24, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 569b806

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@changesets/apply-release-plan Minor
@changesets/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.57%. Comparing base (b8222e6) to head (569b806).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2118      +/-   ##
==========================================
+ Coverage   85.52%   85.57%   +0.05%     
==========================================
  Files          66       66              
  Lines        2535     2544       +9     
  Branches      700      700              
==========================================
+ Hits         2168     2177       +9     
  Misses        337      337              
  Partials       30       30              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

newLines += startNewLinesCount;

// Ensure a minimum of one new line and maximum of two new lines between release lines
const newLinesContent = "\n".repeat(Math.min(Math.max(newLines, 1), 2));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Math.clamp - where are you when we need you?! 😢

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I was disappointed too 😔

@bluwy
bluwy added this pull request to the merge queue Jun 24, 2026
Merged via the queue into main with commit 01f4da4 Jun 24, 2026
12 checks passed
@bluwy
bluwy deleted the improve-changelog-new-line branch June 24, 2026 11:55
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 lines tend to be joined with too many new lines

2 participants