Title: Fix and improve test: message_length_limit by ttw225 · Pull Request #1900 · commitizen-tools/commitizen · GitHub
Open Graph Title: Fix and improve test: message_length_limit by ttw225 · Pull Request #1900 · commitizen-tools/commitizen
X Title: Fix and improve test: message_length_limit by ttw225 · Pull Request #1900 · commitizen-tools/commitizen
Description: 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. - self.max_msg_length = arguments.get( - "message_length_limit", config.settings.get("message_length_limit", 0) + + message_length_limit = arguments.get("message_length_limit") + self.message_length_limit: int = ( + message_length_limit + if message_length_limit is not None + else config.settings["message_length_limit"] ) 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. unit tests: test_commit_command.py, test_check_command.py integration tests: tests/test_cli_config_integration.py Checklist I have read the contributing guidelines Was generative AI tooling used to co-author this PR? Yes (please specify the tool below) Generated-with: [Cursor] following the guidelines Code Changes Add test cases to all the changes you introduce Run uv run poe 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 Expected Behavior When message_length_limit is configured, cz commit / cz check should enforce it unless explicitly overridden via -l/--message-length-limit (including -l 0 to disable the limit). Steps to Test This Pull Request Steps to reproduce the behavior: Create a temp repo with a pyproject.toml containing: [tool.commitizen] name = "cz_conventional_commits" message_length_limit = 10 Confirm config is enforced (should fail): cz check --message "feat: this is definitely too long" Confirm CLI overrides config (should succeed): cz check -l 0 --message "feat: this is definitely too long" Additional Context #1899
Open Graph Description: 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&q...
X Description: 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_lim...
Opengraph URL: https://github.com/commitizen-tools/commitizen/pull/1900
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:f081b0e3-c117-b513-1477-408e5ebfa3cb |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 903C:C3948:10210D1:1686ADB:6A4E97F6 |
| html-safe-nonce | 1c53516f400440b5b1c2ef9549710ba4cc58ab1488e8a1c35d660168b4681a7f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MDNDOkMzOTQ4OjEwMjEwRDE6MTY4NkFEQjo2QTRFOTdGNiIsInZpc2l0b3JfaWQiOiI3MzQ4Mjk4MzkxMDY2MTExOTAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | e9e1bd98b0c78b6a68e3b2838fabd2c61041a94d85792198f78b3365748a2653 |
| hovercard-subject-tag | pull_request:3413670369 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/commitizen-tools/commitizen/pull/1900/files |
| twitter:image | https://avatars.githubusercontent.com/u/35064951?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/35064951?s=400&v=4 |
| og:image:alt | 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&q... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 41b6ab3ba6d20a71766ac245b5a4a94c6fc672a9cd4da7d44c1b33ab8bf6a21c |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/commitizen-tools/commitizen git https://github.com/commitizen-tools/commitizen.git |
| octolytics-dimension-user_id | 62252524 |
| octolytics-dimension-user_login | commitizen-tools |
| octolytics-dimension-repository_id | 106127589 |
| octolytics-dimension-repository_nwo | commitizen-tools/commitizen |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 106127589 |
| octolytics-dimension-repository_network_root_nwo | commitizen-tools/commitizen |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | e6a744804e8e70f97b4d5a18a94dcc63db22f97a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width