bahmutov / pre-git

Automatically install pre-commit / pre-push hooks in your git repo
168 stars 22 forks source link

feat(config): allow custom error message for pattern validation #104

Closed hmagrini closed 7 years ago

hmagrini commented 7 years ago

Feature:

This PR adds a msg-pattern-error property to the config object to allow custom error logs when the validation performed by msg-pattern fails.

Motivation:

Currently when validation for msg-pattern fails, only the pre-commit hook logs a message in the console ("pre-commit Nothing the hook needs to do. Bailing out.") since the checkMessageAgainstPattern method only calls the debug log function when validation fails.

We are shipping a new major release for our core components which includes pre-git and several tools for conventional releases, and I've have encountered several cases of devs not knowing about pre-git usage (even though all repos clearly state that it's being used and how the message pattern should be written) and since no clear error message is shown in the console, they just opted into using the --no-verify option.

I was torn between just changing the debug log method into just console.error and adding and additional option to the config, but I thought that maybe this was more helpful since it allows more customization (i.e.: we could direct devs to the documentation regarding our message pattern instead of logging the regex string)

bahmutov commented 7 years ago

Nice feature, thank you very much.