From 40731b940929289cb8a61503deba78c3893e5f45 Mon Sep 17 00:00:00 2001 From: MarioCadenas Date: Wed, 6 May 2026 18:48:22 +0200 Subject: [PATCH] ci: align breaking-change detector with release-it parser semantics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Verified the regex case-by-case against `conventional-changelog-conventionalcommits` (the parser release-it actually uses) and tightened it so it matches release-it's notion of "this triggers a major bump" exactly: - Case-insensitive match on both subject `type!:` and the `BREAKING[ -]CHANGE` footer keyword (e.g. `Feat!:` and `breaking change: ...` both bump major in release-it). - Footer line allows leading whitespace (release-it accepts ` BREAKING CHANGE: ...`). - Footer keyword no longer requires a `:` (release-it accepts `BREAKING CHANGE foo`); we now end on a word boundary. - Plural `BREAKING CHANGES` is explicitly excluded with `\b(?!S)` because release-it does NOT treat it as breaking — flagging it would be a false positive that blocks harmless prose. --- tools/detect-breaking-commits.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/detect-breaking-commits.ts b/tools/detect-breaking-commits.ts index a5896c2a..4fc30ff9 100644 --- a/tools/detect-breaking-commits.ts +++ b/tools/detect-breaking-commits.ts @@ -27,11 +27,16 @@ const TRACKED_PATHS = [ "packages/shared", ]; -// Conventional Commits breaking-change markers: -// 1. `type!:` or `type(scope)!:` in the subject line -// 2. `BREAKING CHANGE:` or `BREAKING-CHANGE:` footer line +// Matches what `conventional-changelog-conventionalcommits` (used by +// release-it) treats as a major-bumping breaking change. Verified against +// the live parser; covers: +// - Subject `type!:` / `type(scope)!:` (case-insensitive) +// - Footer line `BREAKING CHANGE` or `BREAKING-CHANGE`, with optional +// leading whitespace, optional colon, case-insensitive +// Excludes the plural `BREAKING CHANGES` (parser does NOT treat it as +// breaking — `\b(?!S)` enforces this) and mid-line / list-item occurrences. const BREAKING_PATTERN = - /^(feat|fix|chore|refactor|perf|build|ci|docs|style|test|revert)(\([^)]+\))?!:|^BREAKING[ -]CHANGE:/m; + /^(feat|fix|chore|refactor|perf|build|ci|docs|style|test|revert)(\([^)]+\))?!:|^\s*BREAKING[ -]CHANGE\b(?!S)/im; function requireEnv(name: string): string { const value = process.env[name];