Skip to content

Conversation

Narwhal-fish
Copy link

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] <[email protected]>
@Narwhal-fish
Copy link
Author

Sorry, I accidentally closed this pull request.

@Lee-W
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
@Narwhal-fish
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.

@Lee-W
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

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

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

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

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

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

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.

@Lee-W
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
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants