Skip to content

feat(changelog): allow overriding the changelog context - #370

Merged
TimothyJones merged 2 commits into
absolute-version:masterfrom
lyn1dev:feat/changelog-context
Nov 24, 2026
Merged

TimothyJones merged 2 commits into
absolute-version:masterfrom
lyn1dev:feat/changelog-context

Conversation

@lyn1dev

@lyn1dev lyn1dev commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Problem

The changelog generator's context was passed as a fixed object:

.context({ version: newVersion })

Because of that, the values the changelog template renders from could not be
changed. For example, setting linkCompare: false or linkReferences: false (or
the commitUrlFormat/compareUrlFormat templates to an empty string, as in
#216) had no effect: the version heading, commit hashes and closes #123
references were still rendered as links.

Change

A new context option is merged into the generator context:

.context({ ...args.context, version: newVersion })

It can be set in .versionrc / the commit-and-tag-version key of
package.json:

{
  "commit-and-tag-version": {
    "context": {
      "linkCompare": false,
      "linkReferences": false
    }
  }
}

version stays authoritative, since it is the version being released. The
option is documented in the "Customizing CHANGELOG Generation" section of the
readme.

Testing

  • Added test/changelog-context.integration-test.js, which runs the CLI against
    a real temporary git repository (with a v1.0.0 tag and a feat: commit) and
    a package.json carrying a repository url:
    • the default run still links the compare range and the commit hash;
    • with context: { linkCompare: false, linkReferences: false }, the changelog
      is generated without the compare range and commit-hash links.
  • npx vitest run test/changelog-context.integration-test.js:
    • without the change to lib/lifecycles/changelog.js: 1 failed | 1 passed
      (applies the configured context to the changelog fails, the default case
      passes);
    • with the change: 2 passed.
  • npm test (vitest with coverage, then eslint . and
    prettier "./**/*.{ts,js}" --check): 15 test files, 163 tests passed; lint and
    format checks clean.

Fixes #216

AI was used to write this code.

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.
Comment thread README.md Resolved
@TimothyJones
TimothyJones merged commit f4be71f into absolute-version:master Nov 24, 2026
9 checks passed
@TimothyJones

Copy link
Copy Markdown
Member

Thanks for this! I'll get it released shortly

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.

Is there a way to disable compare and commit urls?

2 participants