Repository navigation
feat(changelog): allow overriding the changelog context - #370
Merged
TimothyJones merged 2 commits intoNov 24, 2026
Merged
Conversation
The changelog generator context was fixed to the version being released, so values the template renders from (such as linkCompare and linkReferences) could not be changed. Merge a configured context into it, keeping the version authoritative.
TimothyJones
requested changes
Nov 24, 2026
TimothyJones
approved these changes
Nov 24, 2026
Member
|
Thanks for this! I'll get it released shortly |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The changelog generator's context was passed as a fixed object:
Because of that, the values the changelog template renders from could not be
changed. For example, setting
linkCompare: falseorlinkReferences: false(orthe
commitUrlFormat/compareUrlFormattemplates to an empty string, as in#216) had no effect: the version heading, commit hashes and
closes #123references were still rendered as links.
Change
A new
contextoption is merged into the generator context:It can be set in
.versionrc/ thecommit-and-tag-versionkey ofpackage.json:{ "commit-and-tag-version": { "context": { "linkCompare": false, "linkReferences": false } } }versionstays authoritative, since it is the version being released. Theoption is documented in the "Customizing CHANGELOG Generation" section of the
readme.
Testing
test/changelog-context.integration-test.js, which runs the CLI againsta real temporary git repository (with a
v1.0.0tag and afeat:commit) anda
package.jsoncarrying arepositoryurl:context: { linkCompare: false, linkReferences: false }, the changelogis generated without the compare range and commit-hash links.
npx vitest run test/changelog-context.integration-test.js:lib/lifecycles/changelog.js: 1 failed | 1 passed(
applies the configured context to the changelogfails, the default casepasses);
npm test(vitest with coverage, theneslint .andprettier "./**/*.{ts,js}" --check): 15 test files, 163 tests passed; lint andformat checks clean.
Fixes #216
AI was used to write this code.