Conversation
Treat an omitted CLI option as no override so project configuration controls body wrapping while an explicit zero continues to disable it. Fixes commitizen-tools#2093 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 #2094 +/- ##
=======================================
Coverage 98.27% 98.27%
=======================================
Files 61 61
Lines 2836 2838 +2
=======================================
+ Hits 2787 2789 +2
Misses 49 49 ☔ View full report in Codecov by Harness. |
| extra_cli_args: list[str] | ||
| message_length_limit: int | ||
| body_length_limit: int | ||
| body_length_limit: int | None |
There was a problem hiding this comment.
I find allowing a None value very confusing... we may need to redesign the configuration system at some point
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The implementation correctly distinguishes an omitted option from an explicit zero and includes focused regression coverage.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes cz commit so configured body wrapping applies when no CLI override is supplied.
Changes:
- Treats
Noneas an omitted CLI option. - Preserves explicit
0as disabling wrapping. - Adds regression coverage for configured limits.
| File | Description |
|---|---|
commitizen/commands/commit.py |
Falls back to the configured body limit. |
tests/commands/test_commit_command.py |
Tests omitted CLI-option behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Description
Make
cz commithonorbody_length_limitfrom project configuration when--body-length-limitis omitted.The argument parser supplies
Nonefor an omitted option. That value previouslymasked the configured limit because
dict.get()only used its default when thekey was absent. The command now treats
Noneas no CLI override while retainingthe existing behavior where an explicit
--body-length-limit 0disableswrapping.
Fixes #2093.
Checklist
Was generative AI tooling used to co-author this PR?
Generated-by: GitHub Copilot CLI following the guidelines
Code Changes
uv run poe alllocally to ensure this change passes linter check and teststhe hook-integration tests attempted to install Prettier; npm and node
rejected the local TLS issuer. Ruff, mypy, and all 35 commit-command tests
pass.
configuration and CLI semantics are unchanged
Documentation Changes
Not applicable.
uv run poe doclocally to ensure the documentation pages renders correctlyExpected Behavior
cz commitwraps body lines at the configuredbody_length_limitwhen no CLIoverride is provided. Passing
--body-length-limit 0still disables wrapping.Steps to Test This Pull Request
body_length_limit = 20.cz commitwithout--body-length-limitand enter a body line longerthan 20 characters.
--body-length-limit 0and verify that wrapping is disabled.uv run pytest tests/commands/test_commit_command.py.Additional Context
The regression test exercises the same
Nonevalue produced by argparse whenthe CLI option is omitted. Collected coverage remains 98% overall and 99% for
commitizen/commands/commit.py; all newly added executable lines are covered.