Skip to content

Gather commits no release contains under an Unreleased heading - #17

Merged
cjbarth merged 3 commits into
masterfrom
fix/unreleased-section
Sep 16, 2026
Merged

cjbarth merged 3 commits into
masterfrom
fix/unreleased-section

Conversation

@cjbarth

@cjbarth cjbarth commented Sep 16, 2026

Copy link
Copy Markdown
Owner

The bug

The section at the top of the changelog was only written when the version in package.json had no tag:

if (head && unreleasedVersion && !tags.some((tag) => tag.version === unreleasedVersion)) {

That holds at release time, because release-it bumps the version before it tags, which is why releases came out right. It stops holding the moment the tag exists. So between one release and the next, every pull request merged to master was left out of the changelog — silently, with no warning and nothing in the report.

Generating for this repository right now, with 5.1.0 in package.json and tagged, produced no top section at all.

The fix

Commits the branch holds that no tag contains are now gathered under an Unreleased heading. It appears only when there is something in it, carries no version for prefix to attach to (so it reads ## Unreleased, not ## vUnreleased), and is never frozen, since its date is always now.

The named-version section is unchanged: when package.json names a version that has no tag, that version still titles the top block, so the release flow behaves exactly as before.

A warning that was wrong

semver.gte meant the "branch already contains" warning fired in the ordinary state between releases, where the version equals a tag. It now fires only when package.json is genuinely behind a tag the branch holds — the case where someone forgot to bump — and says what happens to the work rather than claiming it is skipped:

The version being prepared, 1.1.5, is older than v2.0.0, which master already
contains. Commits no tag holds are listed as Unreleased.

Three existing tests changed, each for a reason

  • An explicitly selected tag now comes back alongside an Unreleased section when the branch has later work. That matches how the named-version section has always behaved with --tags.
  • The test asserting the branch is not read when the version is tagged is no longer true: the branch is read, to find out whether anything is unreleased. It now covers the case where nothing is read — a branch level with a tag.
  • The shallow-clone test is detached, so it has no branch; it passes head: "HEAD".

Verification

129 tests with a token, 89 without. Generated against this repository from a branch one commit ahead of v5.1.0, the output opens with ## Unreleased, and the commit is reported as having no pull request — correct, since this pull request is not merged yet.

🤖 Generated with Claude Code

cjbarth and others added 3 commits September 16, 2026 14:40
The section at the top of the changelog was only written when the
version in package.json had no tag, which is true at release time
because release-it bumps the version before it tags. After the release
it is false, so pull requests merged between one release and the next
were left out of the changelog with nothing said about them.

They are now gathered under an Unreleased heading, which has no version
for the prefix to belong to, and appears only when the branch has
something no tag contains.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Whether a commit is beyond every tag and whether anything can be said
about it are different questions. The heading was written for the
first, so a commit whose pull request is still open produced a heading
with "no changelog for this release" under it, which is noise: the
commit is in the report either way.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Everything a reader sees is a template value, so that a project can
word it, or translate it, as it likes. Two strings were written into
the code instead: the Unreleased heading, and the sentence for a
release with nothing to list.

The second is why node-saml's configuration replaces that sentence
inside its release template; it can set template.noChangelog instead.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@cjbarth
cjbarth merged commit e74aaa5 into master Sep 16, 2026
2 checks passed
@cjbarth
cjbarth deleted the fix/unreleased-section branch September 16, 2026 19:55
@cjbarth cjbarth added the bug Something isn't working label Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant