Repository navigation
Conversation
Use the configured limit when commit and check receive no CLI override. Preserve explicit zero to disable the limit. Assisted By: AI Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2124 +/- ##
=======================================
Coverage 98.29% 98.29%
=======================================
Files 61 61
Lines 2866 2870 +4
=======================================
+ Hits 2817 2821 +4
Misses 49 49 ☔ View full report in Codecov by Harness. |
This branch has not been deployed
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
Make
cz commitandcz checkhonor configuredmessage_length_limitwhen the CLI option is omitted.Treat argparse's
Noneas no CLI override, using the same approach as #2094. Preserve explicit-l 0to disable the limit. Add regression tests and clarify configuration precedence.Fixes #1899.
Checklist
Was generative AI tooling used to co-author this PR?
Generated-by: GitHub Copilot CLI following the guidelines
Assisted By: AI
Code Changes
uv run poe alllocally to ensure this change passes linter check and testsDocumentation Changes
uv run poe doclocally to ensure the documentation pages renders correctlyExpected Behavior
Both commands use CLI value > configured value > default (
0, no limit). Omitting the CLI option must not disable the configured limit.Steps to Test This Pull Request
message_length_limit = 10under[tool.commitizen].cz check --message "feat: this is definitely too long"without-l; expect rejection.-l 0; expect success.cz commit --dry-runand enter an oversized subject; expect rejection. Repeat with-l 0; expect a dry-run message.Validation completed:
uv run pytest tests/commands/test_commit_command.py tests/commands/test_check_command.py— passed, 80 tests.uv run poe lint— passed, Ruff and mypy.uv run ruff format --check commitizen/commands/commit.py commitizen/commands/check.py tests/commands/test_commit_command.py tests/commands/test_check_command.py— passed.uv run poe doc:build— passed.git diff --check— passed.Additional validation:
PYTEST_XDIST_AUTO_NUM_WORKERS=2 uv run poe all— passed: formatting, Ruff, mypy, commit validation, and coverage suite. Results: 1,334 passed, two skipped, two expected failures; total coverage 98%. Worker count limited for the shared environment.uv run pytest -q /home/y5cstt/.copilot/session-state/1bdcb306-308c-4386-a20c-b1c743083974/files/test_cli_validation.py— passed, 14 real-CLI scenarios in temporary Git repositories, without mocks.checkused subprocesses;commit --dry-runused terminal-driven prompts through pexpect. These were scripted CLI checks, not human keyboard entry.uv run poe doc --dev-addr 127.0.0.1:8765— passed: preview started,/commitizen/config/check/returned HTTP 200, and the updated text was verified in the rendered HTML. Preview stopped after verification.uv run mkdocs build --strict— passed, with no broken-link diagnostics.uv run pytest -q /home/y5cstt/.copilot/session-state/1bdcb306-308c-4386-a20c-b1c743083974/files/test_docs_validation.py— passed, three checks covering all local link targets and fragments plus both external links on the changed rendered page. Links elsewhere in the site were not exhaustively checked.CLI scenarios performed for each command:
-l 0: accepted.-l 72: accepted.-l 10: oversized subject rejected.Each accepted message included a long body to verify that the limit applies only to the subject. Commit checks used
--dry-run; no test commits were created. Validation scripts remained outside the repository. No source changes were needed.Additional Context
This is the message-length equivalent of the body-length fix in #2094 for #2093.