fix(ci): support scoped commit prefixes in PR label extraction (#1032) (#1033)

Strip the scope in parentheses so titles like 'refactor(host): ...'
resolve to the 'refactor' type instead of falling back to 'other'.


(cherry picked from commit 87baf753016132c4fcf8e1166fa9c085de78a206)

Signed-off-by: Andy Lee <andy.lee@suse.com>
Co-authored-by: Andy Lee <andy.lee@suse.com>
This commit is contained in:
mergify[bot] 2026-07-20 15:29:24 +08:00 committed by GitHub
parent e991c9bcc8
commit bcde1744e1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -7,7 +7,11 @@ if (process.argv.length < 3) {
}
const prTitle = process.argv[2];
const prLabel = prTitle.split(':')[0].trim();
// Parse the conventional-commit prefix `type(scope)!:`, keeping only the type
// and dropping an optional scope and breaking-change marker.
const prefixMatch = prTitle.match(/^\s*([a-zA-Z]+)(?:\([^)]*\))?!?:/);
const prLabel = prefixMatch ? prefixMatch[1].toLowerCase() : '';
const config = await load({ extends: ["./commitlint.config.js"] });
const commitPrefix = config?.rules?.['type-enum']?.[2] || [];