Title: feat(cli): add cz --version back and add cz --report to separate them from cz version by bearomorphism · Pull Request #1798 · commitizen-tools/commitizen · GitHub
Open Graph Title: feat(cli): add cz --version back and add cz --report to separate them from cz version by bearomorphism · Pull Request #1798 · commitizen-tools/commitizen
X Title: feat(cli): add cz --version back and add cz --report to separate them from cz version by bearomorphism · Pull Request #1798 · commitizen-tools/commitizen
Description: Description Currently, all of cz version, cz version --commitizen, and cz version --report print the installed Commitizen version / system info. As we extend cz version to also report the project version (see #1785), it makes sense to extract those two installed-Commitizen / bug-report concerns out of the version subcommand and back into top-level flags: cz --version / cz -v — print the installed Commitizen version and exit. cz --report — print Commitizen version, Python version, and OS, intended for bug reports, and exit. The corresponding subcommand options are kept and emit a DeprecationWarning pointing at the new flags; they will be removed in v5. Closes part of #1785. Checklist I have read the contributing guidelines Was generative AI tooling used to co-author this PR? Yes (please specify the tool below) Generated-by: GitHub Copilot 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 (cz version --commitizen / cz version --report keep working with deprecation warnings) Document any manual testing steps performed (see below) Update the documentation for the changes Documentation Changes Run uv run poe doc locally to ensure the documentation pages renders correctly Check and fix any broken links (internal or external) Expected Behavior Invocation Behavior cz --version / cz -v Print installed Commitizen version. Takes precedence over any subcommand. cz --report Print Commitizen version, Python version, OS. Only takes effect when no subcommand is given. cz --report version Runs the version subcommand (top-level --report is a "no subcommand" flag — kept simple by design). cz version --commitizen Still works, emits DeprecationWarning pointing at cz --version. cz version --report Still works, emits DeprecationWarning pointing at cz --report. cz --invalid-arg Errors with argparse unrecognized arguments: --invalid-arg (previously silently fell through). cz (no args) Prints help — unchanged. cz invalidCommand argparse invalid choice error — unchanged. Steps to Test This Pull Request uv sync --frozen --group base --group test --group linters # New top-level flags uv run cz --version uv run cz -v uv run cz --report # Deprecated subcommand flags still work uv run cz version --commitizen # emits DeprecationWarning uv run cz version --report # emits DeprecationWarning # Unknown args now error properly uv run cz --invalid-arg # exits 13, prints argparse usage + "unrecognized arguments" # Regression tests uv run pytest tests/test_cli.py tests/commands/test_version_command.py uv run poe lint Additional Context Related: #1785. Reviewer feedback addressed in this PR: Empty tests/test_cli/test_invalid_command_py_*___invalid_arg_.txt baselines were a side effect of changing subcommands.required to False (needed so the new top-level flags work without a subcommand). parse_known_args() then silently swallowed --invalid-arg. Fixed by re-running parser.parse_args() when there is no subcommand and unknown args are present, so argparse's unrecognized arguments error reaches stderr; baselines regenerated for Python 3.10–3.14. The earlier suggestion to make cz --report version route to the top-level --report was intentionally left as-is: --report stays a simple "no subcommand" flag (per @woile's note: existing cz version --* options are kept until all the new features are out, then removed in v5).
Open Graph Description: Description Currently, all of cz version, cz version --commitizen, and cz version --report print the installed Commitizen version / system info. As we extend cz version to also report the project v...
X Description: Description Currently, all of cz version, cz version --commitizen, and cz version --report print the installed Commitizen version / system info. As we extend cz version to also report the project v...
Opengraph URL: https://github.com/commitizen-tools/commitizen/pull/1798
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:9b776d45-2c9f-06fe-cda4-425bcf68dbf4 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | CDD8:28E279:338FEB9:346A692:6A4F05CB |
| html-safe-nonce | e7dd01c0243a2a6b7e56f812259a75045109dd8cf72db0a970d1613c94494ae9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDREQ4OjI4RTI3OTozMzhGRUI5OjM0NkE2OTI6NkE0RjA1Q0IiLCJ2aXNpdG9yX2lkIjoiNjE2MDQyNzk3ODQ5MDU3ODM3OSIsInJlZ2lvbl9lZGdlIjoic2VhIiwicmVnaW9uX3JlbmRlciI6InNlYSJ9 |
| visitor-hmac | 081afecc9c43875987f2b98004c88eefad8c0c62f2967caae4b465e19dd27e9a |
| hovercard-subject-tag | pull_request:3172014184 |
| 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/1798/files |
| twitter:image | https://avatars.githubusercontent.com/u/26526132?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/26526132?s=400&v=4 |
| og:image:alt | Description Currently, all of cz version, cz version --commitizen, and cz version --report print the installed Commitizen version / system info. As we extend cz version to also report the project v... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | b92d11c0aa4a77d54ef4af1078b6a15fb5a70a215b30c4ecf28889d5a8e656d9 |
| 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 | 2b8f23afb982271f1b22258a94aede67a6b77760 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width