-
-
Notifications
You must be signed in to change notification settings - Fork 301
feat: add an argument to limit the length of commit message #1076
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
2c03a94
1d2172e
ab75e34
d0f3a4a
0d7eaee
39792f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
from commitizen.cz.utils import get_backup_file_path | ||
from commitizen.exceptions import ( | ||
CommitError, | ||
CommitMessageLengthExceededError, | ||
CustomError, | ||
DryRunExit, | ||
NoAnswersError, | ||
|
@@ -61,7 +62,16 @@ def prompt_commit_questions(self) -> str: | |
|
||
if not answers: | ||
raise NoAnswersError() | ||
return cz.message(answers) | ||
|
||
message = cz.message(answers) | ||
message_len = len(message.partition("\n")[0]) | ||
|
||
message_length_limit: int = self.arguments.get("message_length_limit", 0) | ||
if message_length_limit > 0 and message_len > message_length_limit: | ||
Lee-W marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
raise CommitMessageLengthExceededError( | ||
f"Length of commit message exceeds limit ({message_len}/{message_length_limit})" | ||
) | ||
|
||
return message | ||
|
||
def __call__(self): | ||
dry_run: bool = self.arguments.get("dry_run") | ||
|