semantic-release / semantic-release/release-notes-generator

Allow to overwrite `whatBump` function from presets

Open
#741 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
368
Forks
55
Avg merge
10m
Merged PRs (30d)
1

Description

Hi, currently we are able to overwrite parserOpts and writerOpts:

https://github.com/semantic-release/release-notes-generator/blob/354354b1dabf404bebd637ab7850f3d0402aa325/lib/load-changelog-config.js#L35-L39

but we miss a capability to overwrite whatBump() function used by presets, e.g. conventional-changelog-conventionalcommits:

export default async function createPreset (config) {
  return {
    commits: {
      ignore: config?.ignoreCommits,
      merges: false
    },
    parser: createParserOpts(config),
    writer: await createWriterOpts(config),
    whatBump: createWhatBump(config)
  }
}

In case of this specific preset, whatBump() impacts the generated release notes because of a) commit object modification (which is a preset issue itself) b) hardcoded breakingHeaderPattern here:

export const breakingHeaderPattern = /^(\w*)(?:\((.*)\))?!: (.*)$/

which ignores the breakingHeaderPattern value passed to parserOpts (which, I guess, makes sense as whatBump() is a separate function). If we could overwrite a function - we would be able to align parser and whatBump() logic on our end.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Begin with lib/load-changelog-config.js at the linked parserOpts and writerOpts handling, then trace how presets supply whatBump, especially in conventional-changelog-conventionalcommits. Confirm that a caller can replace that function and that generated release notes use the replacement, including the breaking-header case.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
release, tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.