From 69cd0ccdbb5ef77d85b76a65fece80e70c3c6ebf Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 27 Jun 2026 11:37:19 +0000 Subject: [PATCH] refactor(githooks): use non-capturing groups for unread regex captures The commit-msg header regex captured the optional scope and breaking-change marker but never read them. Make those groups non-capturing so only the type and subject are captured, per review feedback. --- .githooks/check-conventional-commit.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.githooks/check-conventional-commit.mjs b/.githooks/check-conventional-commit.mjs index c18445e715..9add66fc69 100644 --- a/.githooks/check-conventional-commit.mjs +++ b/.githooks/check-conventional-commit.mjs @@ -80,14 +80,14 @@ function collectErrors (header) { errors.push(`header is ${header.length} characters; keep it within ${HEADER_MAX_LENGTH}`) } - const match = /^([^():!]+)(\([^)]*\))?(!)?: (.*)$/.exec(header) + const match = /^([^():!]+)(?:\([^)]*\))?(?:!)?: (.*)$/.exec(header) if (!match) { errors.push('header must match "type(optional scope): subject", e.g. "fix(core): handle empty input"') return errors } const type = match[1] - const subject = match[4] + const subject = match[2] if (type !== type.toLowerCase()) { errors.push(`type "${type}" must be lower-case`)