-
-
Notifications
You must be signed in to change notification settings - Fork 281
feat: check if commit message is no more than 72 characters #557
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
feat: check if commit message is no more than 72 characters #557
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
@@ -29,6 +29,8 @@ def __init__(self, config: BaseConfig, arguments: dict): | |||
self.config: BaseConfig = config | |||
self.cz = factory.commiter_factory(self.config) | |||
self.arguments = arguments | |||
print(self.config) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we make it configurable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -44,7 +45,7 @@ def questions(self) -> Questions: | |||
] | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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): subject
part) does not exceed 72 characters.Currently only supports ConventionalCommitsCz; JiraSmartCz and CustomizeCommitsCz not implemented.
An imperfect workaround for #191.
Checklist
./scripts/format
and./scripts/test
locally to ensure this change passes linter check and testExpected behavior
If run
cz commit
with-cl
or--check-length
argument, the commit would fail whenprefix(scope): subject
is longer than 72 chars.Without the argument, the default behavior is to accept longer messages.
Steps to Test This Pull Request
cz commit -cl
Then cz should exit with message
Length of commit message exceeded limit (73/72)
and error code 23.Additional context