Skip to content

fix(hook): show actual regex pattern in commit-msg-hook error#191

Closed
A386official wants to merge 1 commit intoqoomon:masterfrom
A386official:fix/show-custom-regex-in-error-message
Closed

fix(hook): show actual regex pattern in commit-msg-hook error#191
A386official wants to merge 1 commit intoqoomon:masterfrom
A386official:fix/show-custom-regex-in-error-message

Conversation

@A386official
Copy link

Hi! I noticed the bug reported in #180 where the pre-commit hook error message always shows the default pattern instead of the custom one when commitMessageRegexPattern is configured.

What

When a custom commitMessageRegexPattern is set in the config file, the commit-msg-hook error message still displays the hardcoded default pattern <TYPE>[(<SCOPE>)]: <DESCRIPTION> instead of the actual regex being used for validation.

Why

The error message on line 31 of commandCommitMessageHook.js uses a hardcoded string literal rather than reading from the loaded convention config. Since the config loader already compiles the custom pattern into convention.msgRegex, this information is available but was not being used.

How

Replace the hardcoded pattern string with convention.msgRegex.source, which contains the actual regex pattern string being used for validation (whether default or custom). This way users see exactly which pattern their commit message needs to match.

Closes #180

When a custom commitMessageRegexPattern is configured, the
commit-msg-hook error message still shows the hardcoded default
pattern <TYPE>[(<SCOPE>)]: <DESCRIPTION> instead of the actual
regex being used for validation. Display convention.msgRegex.source
so users see which pattern their commit must match.

Closes #180
@A386official A386official closed this by deleting the head repository Mar 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pre-commit hook error message does not state the correct commitMsgRegexPattern

1 participant