feat: check if commit message is no more than 72 characters#557
feat: check if commit message is no more than 72 characters#557kevin1kevin1k wants to merge 0 commit intocommitizen-tools:masterfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## master #557 +/- ##
==========================================
- Coverage 98.25% 98.25% -0.01%
==========================================
Files 39 39
Lines 1551 1604 +53
==========================================
+ Hits 1524 1576 +52
- Misses 27 28 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
commitizen/commands/commit.py
Outdated
| self.config: BaseConfig = config | ||
| self.cz = factory.commiter_factory(self.config) | ||
| self.arguments = arguments | ||
| print(self.config) |
There was a problem hiding this comment.
I'd suggest we don't print anything not directly related to cz commit
| message = f"{prefix}{scope}: {subject}{body}{footer}" | ||
| message = f"{prefix}{scope}: {subject}" | ||
| message_len = len(message) | ||
| MESSAGE_LEN_LIMIT = 72 |
There was a problem hiding this comment.
Also, in the comment #191 (comment), he proposes a reasonable solution. Although global variables might sometimes not be desired. I'm good with it in this case. @kevin1kevin1k @woile What do you think?
commitizen/cz/jira/jira.py
Outdated
| return questions | ||
|
|
||
| def message(self, answers) -> str: | ||
| def message(self, answers: dict, check_length: Optional[bool] = False) -> str: |
There was a problem hiding this comment.
Maybe we could implement such check on customize and jira as well 🤔
|
What's the status of this PR? Do we still want this feature? |
|
I think this feature is still what we want but do not have bandwidth to work on it at this moment |
|
This PR is useful. What is missing to get it merged? |
I think we should make it a configurable feature. |
|
@kevin1kevin1k Could you please make |
|
Sorry for the late response. |
|
Hey :) |
|
Thanks for the reminder! |
44c145d to
99db128
Compare
Description
Check if the length of commit message (the
prefix(scope): subjectpart) does not exceed 72 characters.Currently only supports ConventionalCommitsCz; JiraSmartCz and CustomizeCommitsCz not implemented.
An imperfect workaround for #191.
Checklist
./scripts/formatand./scripts/testlocally to ensure this change passes linter check and testExpected behavior
If run
cz commitwith-clor--check-lengthargument, the commit would fail whenprefix(scope): subjectis longer than 72 chars.Without the argument, the default behavior is to accept longer messages.
Steps to Test This Pull Request
cz commit -clThen cz should exit with message
Length of commit message exceeded limit (73/72)and error code 23.Additional context