Fix and improve test: message_length_limit#1900
Open
ttw225 wants to merge 7 commits intocommitizen-tools:masterfrom
Open
Fix and improve test: message_length_limit#1900ttw225 wants to merge 7 commits intocommitizen-tools:masterfrom
ttw225 wants to merge 7 commits intocommitizen-tools:masterfrom
Conversation
CLI > config > default (0) for not limit
CLI > config > default (0) for not limit
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1900 +/- ##
=======================================
Coverage 97.99% 97.99%
=======================================
Files 60 60
Lines 2689 2691 +2
=======================================
+ Hits 2635 2637 +2
Misses 54 54 ☔ View full report in Codecov by Sentry. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes how message_length_limit is resolved when the CLI flag is unset. Previously, the CLI argument could be present as None, causing arguments.get("message_length_limit", ...) to return None and skip the config fallback—so the configured limit (e.g. in pyproject.toml) was effectively ignored.
Now the precedence is correctly enforced as CLI > config > default (0 = no limit) for both cz commit and cz check, and additional unit + integration tests are added to prevent regressions.
test_commit_command.py,test_check_command.pytests/test_cli_config_integration.pyChecklist
Was generative AI tooling used to co-author this PR?
Generated-with: [Cursor] following the guidelines
Code Changes
uv run poe alllocally to ensure this change passes linter check and testsExpected Behavior
When
message_length_limitis configured,cz commit / cz checkshould enforce it unless explicitly overridden via-l/--message-length-limit(including-l 0to disable the limit).Steps to Test This Pull Request
Steps to reproduce the behavior:
pyproject.tomlcontaining:cz check --message "feat: this is definitely too long"cz check -l 0 --message "feat: this is definitely too long"Additional Context
#1899