commitizen icon indicating copy to clipboard operation
commitizen copied to clipboard

feat: check if commit message is no more than 72 characters

Open kevin1kevin1k opened this issue 3 years ago • 9 comments

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/format and ./scripts/test locally 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

  1. cz commit -cl
  2. ENTER (type prefix: fix)
  3. ENTER (empty scope)
  4. 01234567890123456789012345678901234567890123456789012345678901234567 (for subject)
  5. ENTER (empty body)
  6. ENTER (not breaking change)
  7. ENTER (no footer)

Then cz should exit with message Length of commit message exceeded limit (73/72) and error code 23.

Additional context

kevin1kevin1k avatar Aug 14 '22 08:08 kevin1kevin1k

Codecov Report

Merging #557 (44c145d) into master (764861f) will decrease coverage by 0.00%. The diff coverage is 98.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.

codecov[bot] avatar Aug 14 '22 08:08 codecov[bot]

What's the status of this PR? Do we still want this feature?

woile avatar Apr 28 '23 10:04 woile

I think this feature is still what we want but do not have bandwidth to work on it at this moment

Lee-W avatar May 06 '23 10:05 Lee-W

This PR is useful. What is missing to get it merged?

schlotter avatar Jul 14 '23 15:07 schlotter

This PR is useful. What is missing to get it merged?

I think we should make it a configurable feature.

Lee-W avatar Jul 15 '23 08:07 Lee-W

@kevin1kevin1k Could you please make MESSAGE_LEN_LIMIT configurable? I think this would be a much wanted improvement!

schlotter avatar Jul 16 '23 20:07 schlotter

Sorry for the late response. I will find time to resolve the comments and make it configurable!

kevin1kevin1k avatar Jul 18 '23 15:07 kevin1kevin1k

Hey :) What's the status of this PR? @kevin1kevin1k - do you think you'll have some time to wrap it up 🙇 ?

nowNick avatar Nov 03 '23 14:11 nowNick

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.

kevin1kevin1k avatar Nov 06 '23 12:11 kevin1kevin1k