Skip to content

feat(cli): add cz --version back and add cz --report to separate them from cz version#1798

Draft
bearomorphism wants to merge 6 commits intomasterfrom
feat-version-report
Draft

feat(cli): add cz --version back and add cz --report to separate them from cz version#1798
bearomorphism wants to merge 6 commits intomasterfrom
feat-version-report

Conversation

@bearomorphism
Copy link
Copy Markdown
Collaborator

Description

As we are extending the functionality of cz version, I think it would be better to extract the --commitizen and --report from cz version.

Relate #1785

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.24%. Comparing base (efb1a7d) to head (549fbcf).
⚠️ Report is 1 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1798   +/-   ##
=======================================
  Coverage   98.23%   98.24%           
=======================================
  Files          61       61           
  Lines        2772     2787   +15     
=======================================
+ Hits         2723     2738   +15     
  Misses         49       49           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bearomorphism bearomorphism force-pushed the feat-version-report branch 2 times, most recently from 072aa76 to a42800c Compare February 6, 2026 01:57
@bearomorphism
Copy link
Copy Markdown
Collaborator Author

Will deprecate cz version --report and cz version --commitizen

@bearomorphism bearomorphism marked this pull request as draft February 6, 2026 02:50
@woile
Copy link
Copy Markdown
Member

woile commented Feb 8, 2026

Good. Remember that the existing ones, under cz version, we don't remove until all the features are out 👍🏻

@bearomorphism bearomorphism force-pushed the feat-version-report branch from a42800c to fa9331c Compare May 3, 2026 11:33
@bearomorphism bearomorphism marked this pull request as ready for review May 3, 2026 11:40
@bearomorphism bearomorphism requested a review from Copilot May 6, 2026 04:10
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts the Commitizen CLI interface to reintroduce a top-level cz --version/-v and add a top-level cz --report, separating these concerns from the evolving cz version subcommand (per #1785).

Changes:

  • Added global --version/-v handling to print the installed Commitizen version and exit.
  • Added global --report handling to print system info for bug reports and exit.
  • Deprecated cz version --report and cz version --commitizen via warnings, and updated CLI regression snapshots/tests accordingly.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/test_cli/test_no_argv_py_3_14_.txt Updates help output snapshot to include global -v/--version and --report.
tests/test_cli/test_no_argv_py_3_13_.txt Updates help output snapshot to include global -v/--version and --report.
tests/test_cli/test_no_argv_py_3_12_.txt Updates help output snapshot to include global -v/--version and --report.
tests/test_cli/test_no_argv_py_3_11_.txt Updates help output snapshot to include global -v/--version and --report.
tests/test_cli/test_no_argv_py_3_10_.txt Updates help output snapshot to include global -v/--version and --report.
tests/test_cli/test_invalid_command_py_3_14_invalidCommand_.txt Updates invalid-command snapshot to reflect new global options in usage.
tests/test_cli/test_invalid_command_py_3_14___invalid_arg_.txt Modifies invalid-arg snapshot file content (currently emptied in this PR).
tests/test_cli/test_invalid_command_py_3_13_invalidCommand_.txt Updates invalid-command snapshot to reflect new global options in usage.
tests/test_cli/test_invalid_command_py_3_13___invalid_arg_.txt Modifies invalid-arg snapshot file content (currently emptied in this PR).
tests/test_cli/test_invalid_command_py_3_12_invalidCommand_.txt Updates invalid-command snapshot to reflect new global options in usage.
tests/test_cli/test_invalid_command_py_3_12___invalid_arg_.txt Modifies invalid-arg snapshot file content (currently emptied in this PR).
tests/test_cli/test_invalid_command_py_3_11_invalidCommand_.txt Updates invalid-command snapshot to reflect new global options in usage.
tests/test_cli/test_invalid_command_py_3_11___invalid_arg_.txt Modifies invalid-arg snapshot file content (currently emptied in this PR).
tests/test_cli/test_invalid_command_py_3_10_invalidCommand_.txt Updates invalid-command snapshot to reflect new global options in usage.
tests/test_cli/test_invalid_command_py_3_10___invalid_arg_.txt Modifies invalid-arg snapshot file content (currently emptied in this PR).
tests/test_cli.py Adds tests for global --version/-v and --report behavior/precedence.
tests/commands/test_version_command.py Adds tests ensuring deprecated cz version --report/--commitizen emit warnings.
commitizen/commands/version.py Emits deprecation warnings for cz version --report and cz version --commitizen.
commitizen/cli.py Adds global args (--version/-v, --report) and implements top-level handling logic.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread commitizen/cli.py Outdated
Comment on lines +704 to +710
if getattr(args, "report", False) and (
not hasattr(args, "func") or args.func is not commands.Version
):
out.write(f"Commitizen Version: {__version__}")
out.write(f"Python Version: {sys.version}")
out.write(f"Operating System: {platform.system()}")
raise ExpectedExit()
Comment on lines +1 to 4
usage: cz [-h] [--config CONFIG] [--debug] [-n NAME] [-nr NO_RAISE] [-v]
[--report]
{init,commit,c,ls,example,info,schema,bump,changelog,ch,check,version} ...
cz: error: argument {init,commit,c,ls,example,info,schema,bump,changelog,ch,check,version}: invalid choice: 'invalidCommand' (choose from init, commit, c, ls, example, info, schema, bump, changelog, ch, check, version)
@bearomorphism bearomorphism marked this pull request as draft May 6, 2026 04:24
bearomorphism and others added 5 commits May 6, 2026 14:07
Replace raw sys.argv checks with proper argparse-based handling by making
subcommands optional. This fixes three issues:

- cz version --report was intercepted by the top-level handler instead of
  routing to the Version command
- cz -v did not work despite being registered as a shorthand for --version
- cz version --report and cz version --commitizen now emit deprecation
  warnings directing users to use cz --report and cz --version instead

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Top-level meta flags like --version and --report now take priority even
when a subcommand is also provided (e.g., cz --version bump shows the
version instead of running bump). The --report flag correctly defers to
the version subcommand when used as cz version --report.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…d conflict

Use dest='global_report' for the top-level --report flag so it does not
share the same attribute as the version subcommand's --report. This
ensures 'cz --report version' behaves as a top-level report instead of
routing through the version subcommand with a deprecation warning.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Revert the global_report dest approach. Keep --report as a simple
top-level flag that works only without a subcommand, matching the
original intent. Update version.md and README.md to document the new
cz --version/-v and cz --report top-level flags.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bearomorphism bearomorphism force-pushed the feat-version-report branch from 3b5f594 to 12584e3 Compare May 6, 2026 06:07
Consolidate three separate version flag tests into a single parametrized
test. Merge standalone deprecation warning tests into the existing
test_version_for_showing_commitizen_version and
test_version_for_showing_commitizen_system_info tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants