fix: support feat! breaking change notation in semantic-release#46
Conversation
Add parserOpts to commit-analyzer so feat!: and feat(scope)!: are recognized as breaking changes and trigger a major bump. Angular preset v8 headerPattern lacks ! support by default. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Review Summary by QodoSupport feat! breaking change notation in semantic-release
WalkthroughsDescription• Add parserOpts to commit-analyzer for breaking change support • Configure headerPattern to recognize feat! notation • Enable breakingHeaderPattern for major version bumps • Remove unnecessary preset configurations Diagramflowchart LR
A["commit-analyzer config"] -- "add parserOpts" --> B["headerPattern with !"]
B -- "recognize breaking changes" --> C["breakingHeaderPattern"]
C -- "trigger major bump" --> D["semantic versioning"]
File Changes1. release.config.js
|
Code Review by Qodo
1. Greedy scope regex
|
| headerPattern: /^(\w*)(?:\((.*)\))?!?: (.*)$/, | ||
| breakingHeaderPattern: /^(\w*)(?:\((.*)\))?!: (.*)$/, |
There was a problem hiding this comment.
1. Greedy scope regex 🐞 Bug ≡ Correctness
The new headerPattern/breakingHeaderPattern use (.*) for the scope capture, which can consume ) characters from the subject and cause the header regex not to match at all. When that happens, semantic-release parsing can misclassify or skip commits, producing incorrect version bumps and changelog entries.
Agent Prompt
## Issue description
`parserOpts.headerPattern` and `parserOpts.breakingHeaderPattern` use a greedy `.*` inside the optional scope group (`\((.*)\)`), which can over-match when the subject contains `)` and prevent the header from matching.
## Issue Context
This config is used by semantic-release’s commit parsing; if the header regex fails, the commit may be uncategorized/ignored for bumping and/or changelog generation.
## Fix Focus Areas
- release.config.js[6-8]
## Suggested change
Replace `(.*)` with a scope-safe pattern such as `([^)]*)` (or `(.+?)`) in both regexes, e.g.:
- `headerPattern: /^(\w*)(?:\(([^)]*)\))?!?: (.*)$/`
- `breakingHeaderPattern: /^(\w*)(?:\(([^)]*)\))?!: (.*)$/`
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| ["@semantic-release/commit-analyzer", { | ||
| parserOpts: { | ||
| headerPattern: /^(\w*)(?:\((.*)\))?!?: (.*)$/, | ||
| breakingHeaderPattern: /^(\w*)(?:\((.*)\))?!: (.*)$/, | ||
| headerCorrespondence: ["type", "scope", "subject"], | ||
| }, | ||
| ], | ||
| [ | ||
| "@semantic-release/release-notes-generator", | ||
| { | ||
| preset: "conventionalcommits", // 👈 Add this for consistent notes | ||
| }, | ||
| ], | ||
| }], | ||
| "@semantic-release/release-notes-generator", | ||
| [ | ||
| "@semantic-release/changelog", |
There was a problem hiding this comment.
2. Notes parser mismatch 🐞 Bug ≡ Correctness
Only @semantic-release/commit-analyzer is configured with the custom parserOpts, while @semantic-release/release-notes-generator remains unconfigured and will use its default parsing rules. This can produce major version bumps for feat!: commits without corresponding breaking-change content (or correct classification) in the generated release notes and CHANGELOG.md.
Agent Prompt
## Issue description
`@semantic-release/commit-analyzer` has custom `parserOpts` for `!` breaking headers, but `@semantic-release/release-notes-generator` is configured as a bare string. This makes version calculation and notes/changelog generation parse commits differently.
## Issue Context
The changelog plugin consumes the release notes output; if the notes generator doesn’t recognize `feat!:` / `feat(scope)!:` consistently, releases can show a major bump while the notes/CHANGELOG don’t reflect the breaking change correctly.
## Fix Focus Areas
- release.config.js[4-17]
## Suggested change
Configure `@semantic-release/release-notes-generator` with the same `parserOpts` (and, if you intentionally rely on a specific preset, explicitly set it on both plugins as well), e.g.:
```js
["@semantic-release/release-notes-generator", {
parserOpts: {
headerPattern: /^(\w*)(?:\(([^)]*)\))?!?: (.*)$/,
breakingHeaderPattern: /^(\w*)(?:\(([^)]*)\))?!: (.*)$/,
headerCorrespondence: ["type", "scope", "subject"],
},
}],
```
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
🎉 This PR is included in version 2.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Add parserOpts to commit-analyzer so feat!: and feat(scope)!: are recognized as breaking changes and trigger a major bump. Angular preset v8 headerPattern lacks ! support by default.