feat: check if commit message is no more than 72 characters
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
- [x] Add test cases to all the changes you introduce
- [x] Run
./scripts/formatand./scripts/testlocally to ensure this change passes linter check and test - [x] Test the changes on the local machine manually
- [ ] Update the documentation for the changes
Expected behavior
If run cz commit with -cl or --check-length argument, the commit would fail when prefix(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- ENTER (type prefix: fix)
- ENTER (empty scope)
- 01234567890123456789012345678901234567890123456789012345678901234567 (for subject)
- ENTER (empty body)
- ENTER (not breaking change)
- ENTER (no footer)
Then cz should exit with message Length of commit message exceeded limit (73/72) and error code 23.
Additional context
Codecov Report
Merging #557 (44c145d) into master (764861f) will decrease coverage by
0.00%. The diff coverage is98.63%.
@@ 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
| Flag | Coverage Δ | |
|---|---|---|
| unittests | 98.25% <98.63%> (-0.01%) |
:arrow_down: |
Flags with carried forward coverage won't be shown. Click here to find out more.
| Impacted Files | Coverage Δ | |
|---|---|---|
| commitizen/cli.py | 93.93% <ø> (ø) |
|
| ...en/cz/conventional_commits/conventional_commits.py | 98.59% <88.88%> (-1.41%) |
:arrow_down: |
| commitizen/__version__.py | 100.00% <100.00%> (ø) |
|
| commitizen/bump.py | 100.00% <100.00%> (ø) |
|
| commitizen/cmd.py | 100.00% <100.00%> (ø) |
|
| commitizen/commands/changelog.py | 96.62% <100.00%> (+0.03%) |
:arrow_up: |
| commitizen/commands/commit.py | 98.50% <100.00%> (+0.09%) |
:arrow_up: |
| commitizen/commands/init.py | 91.66% <100.00%> (ø) |
|
| commitizen/config/json_config.py | 100.00% <100.00%> (ø) |
|
| commitizen/config/yaml_config.py | 100.00% <100.00%> (ø) |
|
| ... and 6 more |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
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?
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 MESSAGE_LEN_LIMIT configurable? I think this would be a much wanted improvement!
Sorry for the late response. I will find time to resolve the comments and make it configurable!
Hey :) What's the status of this PR? @kevin1kevin1k - do you think you'll have some time to wrap it up 🙇 ?
Thanks for the reminder! I've still been busy lately, but I guess I can find time to finish it up in the upcoming weeks.