Skip to content

Commit be8d7a9

Browse files
fix: return error messages for builtin pattern and length checks
1 parent 866101a commit be8d7a9

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

commitizen/cz/base.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,16 @@ def validate_commit_message(
123123
if max_msg_length:
124124
msg_len = len(commit_msg.partition("\n")[0].strip())
125125
if msg_len > max_msg_length:
126-
return ValidationResult(False, [])
127-
return ValidationResult(bool(re.match(pattern, commit_msg)), [])
126+
return ValidationResult(
127+
False,
128+
[
129+
f"The commit message subject is too long ({msg_len} > {max_msg_length} characters)."
130+
],
131+
)
132+
return ValidationResult(
133+
bool(re.match(pattern, commit_msg)),
134+
[f"The commit message does not match the pattern: {pattern}"],
135+
)
128136

129137
def format_exception_message(
130138
self, ill_formated_commits: list[tuple[git.GitCommit, list]]

docs/customization.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from commitizen import BaseCommitizenCustomizing commitizen is not hard at all.
1+
Customizing commitizen is not hard at all.
22
We have two different ways to do so.
33

44
## 1. Customize in configuration file

0 commit comments

Comments
 (0)