Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: add config option for line length warning #1574

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

Open
Narwhal-fish wants to merge 50 commits into commitizen-tools:v4-9-0-test
base: v4-9-0-test
Choose a base branch
Loading
from Narwhal-fish:feat/Add-config-option-for-line-length-warning

Conversation

Copy link

@Narwhal-fish Narwhal-fish commented Aug 12, 2025

Description

This PR implements configuration file support for the message_length_limit option, addressing issue #1571 . Previously, users could only set commit message length limits via command-line arguments (-l/--message-length-limit). Now they can define a default limit in their configuration file.

Checklist

Code Changes

  • Add test cases to all the changes you introduce
  • Run poetry all locally to ensure this change passes linter check and tests
  • Manually test the changes:
    • Verify the feature/bug fix works as expected in real-world scenarios
    • Test edge cases and error conditions
    • Ensure backward compatibility is maintained
    • Document any manual testing steps performed
  • Update the documentation for the changes

Documentation Changes

  • Run poetry doc locally to ensure the documentation pages renders correctly
  • Check and fix any broken links (internal or external) in the documentation

Expected Behavior

Users can now set default commit message length limits in their configuration file:

[tool.commitizen]
message_length_limit = 72

Steps to Test This Pull Request

  1. Test Configuration File Support
# Add the following to your pyproject.toml:
[tool.commitizen]
message_length_limit = 30
# Test with long message (should fail)
cz check -m "fix: this is a very long commit message that exceeds 30 characters"
# Test with short message (should pass) 
cz check -m "fix: short message"
  1. Test CLI Override
# CLI argument should override config setting
cz check -m "fix: this message is longer than 30 chars but shorter than 60" -l 60
# Disable limit with CLI
cz check -m "fix: very long message that would normally fail config limit" -l 0

Additional Context

bearomorphism and others added 28 commits June 12, 2025 23:07
Bumps [dawidd6/action-homebrew-bump-formula](https://github.com/dawidd6/action-homebrew-bump-formula) from 4 to 5.
- [Release notes](https://github.com/dawidd6/action-homebrew-bump-formula/releases)
- [Commits](dawidd6/action-homebrew-bump-formula@v4...v5)
---
updated-dependencies:
- dependency-name: dawidd6/action-homebrew-bump-formula
 dependency-version: '5'
 dependency-type: direct:production
 update-type: version-update:semver-major
...
Signed-off-by: dependabot[bot] <support@github.com>
Copy link
Author

Sorry, I accidentally closed this pull request.

Lee-W reacted with thumbs up emoji

Copy link
Member

Lee-W commented Aug 12, 2025

let's rebase from v4-9-test

@Narwhal-fish Narwhal-fish force-pushed the feat/Add-config-option-for-line-length-warning branch from 9a2622f to c300b70 Compare August 12, 2025 17:58
Copy link
Author

I have rebased my branch onto v4-9-0.
I’m not very familiar with Git, so please let me know if I missed anything.

Copy link
Member

Lee-W commented Aug 13, 2025

I have rebased my branch onto v4-9-0. I’m not very familiar with Git, so please let me know if I missed anything.

You've done it perfectly 🙂 I'll take a look when bandwidth allow

Narwhal-fish reacted with thumbs up emoji

Copy link
Contributor

@bearomorphism bearomorphism left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! A few suggestion:

raise CommitMessageLengthExceededError(
f"commit validation: failed!\n"
f"commit message length exceeds the limit.\n"
f'commit "": "{commit_msg}"\n'
Copy link
Contributor

@bearomorphism bearomorphism Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does "" mean here

Copy link
Contributor

@bearomorphism bearomorphism Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you forgot to put something like commit hash here in the error message

Copy link
Author

@Narwhal-fish Narwhal-fish Aug 13, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You’re right. I referenced the error handling for invalid messages and forgot to add the commit hash. I’ll make the correction.

@@ -108,6 +109,7 @@ class Settings(TypedDict, total=False):
"always_signoff": False,
"template": None, # default provided by plugin
"extras": {},
"message_length_limit": 0, # 0 for no limit
Copy link
Contributor

@bearomorphism bearomorphism Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we just use None for no limit?

Copy link
Author

@Narwhal-fish Narwhal-fish Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initially, I set it to 0 simply because I thought commit messages wouldn't have a 0-character scenario, but your suggestion of using None is more clear. I've made this change accordingly.

Narwhal-fish and others added 16 commits August 13, 2025 21:20
Original "push" stage has been deprecated since pre-commit v3.2.0. See pre-commit/pre-commit#2732 and pre-commit/pre-commit#2808 for detailed information.
Copy link
Member

Lee-W commented Aug 24, 2025

we might need to resolve the conflict first. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@woile woile Awaiting requested review from woile woile is a code owner

@Lee-W Lee-W Awaiting requested review from Lee-W Lee-W is a code owner

@noirbizarre noirbizarre Awaiting requested review from noirbizarre noirbizarre is a code owner

1 more reviewer

@bearomorphism bearomorphism bearomorphism left review comments

Reviewers whose approvals may not affect merge requirements
Assignees
No one assigned
Labels
Projects
None yet
Milestone
4.9.0
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /