From 0fd770e553b9d1b42c2e733b60e86782077c816e Mon Sep 17 00:00:00 2001 From: abhishek Date: Wed, 19 Nov 2025 20:57:27 +0530 Subject: [PATCH 1/2] feat(bump): add --version-files-only and deprecate --files-only --- commitizen/cli.py | 5 +++++ commitizen/commands/bump.py | 11 ++++++++++- docs/commands/bump.md | 12 +++++++++++- tests/commands/test_bump_command.py | 4 ++-- ...ommand_shows_description_when_use_help_option.txt | 5 +++-- 5 files changed, 31 insertions(+), 6 deletions(-) diff --git a/commitizen/cli.py b/commitizen/cli.py index c11e9078d..f7ed9c839 100644 --- a/commitizen/cli.py +++ b/commitizen/cli.py @@ -208,6 +208,11 @@ def __call__( { "name": "--files-only", "action": "store_true", + "help": "Bump version in the files from the config (This is deprecated and will be removed in v5).", + }, + { + "name": "--version-files-only", + "action": "store_true", "help": "bump version in the files from the config", }, { diff --git a/commitizen/commands/bump.py b/commitizen/commands/bump.py index 3dc678920..11d65fde0 100644 --- a/commitizen/commands/bump.py +++ b/commitizen/commands/bump.py @@ -47,6 +47,7 @@ class BumpArgs(Settings, total=False): dry_run: bool file_name: str files_only: bool | None + version_files_only: bool | None get_next: bool git_output_to_stderr: bool increment_mode: str @@ -356,9 +357,17 @@ def __call__(self) -> None: else None, ) - if self.arguments["files_only"]: + if self.arguments.get("files_only"): + warnings.warn( + "--files-only is deprecated and will be removed in v5. Use --version-files-only instead.", + DeprecationWarning, + ) raise ExpectedExit() + if self.arguments.get("version_files_only"): + raise ExpectedExit() + + # FIXME: check if any changes have been staged git.add(*files) c = git.commit(message, args=self._get_commit_args()) diff --git a/docs/commands/bump.md b/docs/commands/bump.md index eb807f841..3c277da58 100644 --- a/docs/commands/bump.md +++ b/docs/commands/bump.md @@ -109,7 +109,9 @@ Commitizen supports the [PEP 440][pep440] version format, which includes several ![cz bump --help](../images/cli_help/cz_bump___help.svg) -### `--files-only` +### `--files-only` (deprecated) +**Deprecated**: This flag will be removed in Commitizen v5. +Please use [`--version-files-only`](#--version-files-only) instead. Bumps the version in the files defined in [`version_files`](#version_files) without creating a commit and tag on the git repository, @@ -117,6 +119,14 @@ Bumps the version in the files defined in [`version_files`](#version_files) with cz bump --files-only ``` +### `--version-files-only` + +Bumps the version in the files defined in [`version_files`](#version_files) without creating a commit and tag on the git repository, + +```bash +cz bump --version-files-only +``` + ### `--changelog` Generate a **changelog** along with the new version and tag when bumping. See [changelog](./changelog.md) for more details. diff --git a/tests/commands/test_bump_command.py b/tests/commands/test_bump_command.py index 59297b172..67f36d78b 100644 --- a/tests/commands/test_bump_command.py +++ b/tests/commands/test_bump_command.py @@ -555,7 +555,7 @@ def test_bump_files_only(mocker: MockFixture, tmp_commitizen_project): assert tag_exists is True create_file_and_commit("feat: another new feature") - testargs = ["cz", "bump", "--yes", "--files-only"] + testargs = ["cz", "bump", "--yes", "--files-only","--version-files-only"] mocker.patch.object(sys, "argv", testargs) with pytest.raises(ExpectedExit): cli.main() @@ -1427,7 +1427,7 @@ def test_bump_changelog_contains_increment_only(mocker, tmp_commitizen_project, # Add a commit and create the incremental changelog to v3.0.0 # it should only include v3 changes create_file_and_commit("feat(next)!: next version") - testargs = ["cz", "bump", "--yes", "--files-only", "--changelog-to-stdout"] + testargs = ["cz", "bump", "--yes", "--files-only", "--version-files-only", "--changelog-to-stdout"] mocker.patch.object(sys, "argv", testargs) with pytest.raises(ExpectedExit): cli.main() diff --git a/tests/commands/test_bump_command/test_bump_command_shows_description_when_use_help_option.txt b/tests/commands/test_bump_command/test_bump_command_shows_description_when_use_help_option.txt index 4cf8e6c91..cff936e9e 100644 --- a/tests/commands/test_bump_command/test_bump_command_shows_description_when_use_help_option.txt +++ b/tests/commands/test_bump_command/test_bump_command_shows_description_when_use_help_option.txt @@ -1,4 +1,4 @@ -usage: cz bump [-h] [--dry-run] [--files-only] [--local-version] [--changelog] +usage: cz bump [-h] [--dry-run] [--files-only] [--version-files-only] [--local-version] [--changelog] [--no-verify] [--yes] [--tag-format TAG_FORMAT] [--bump-message BUMP_MESSAGE] [--prerelease {alpha,beta,rc}] [--devrelease DEVRELEASE] [--increment {MAJOR,MINOR,PATCH}] @@ -22,7 +22,8 @@ positional arguments: options: -h, --help show this help message and exit --dry-run show output to stdout, no commit, no modified files - --files-only bump version in the files from the config + --files-only bump version in the files from the config (Deprecated in v5) + --version-files-only bump version in the files from the config --local-version bump only the local version portion --changelog, -ch generate the changelog for the newest version --no-verify this option bypasses the pre-commit and commit-msg From 11a766790594bf10b530cd4cf4d96ac58ac6c48a Mon Sep 17 00:00:00 2001 From: abhishek Date: Wed, 19 Nov 2025 22:41:01 +0530 Subject: [PATCH 2/2] change the line of help with adding --version-files --- commitizen/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commitizen/cli.py b/commitizen/cli.py index f7ed9c839..57732ee4d 100644 --- a/commitizen/cli.py +++ b/commitizen/cli.py @@ -208,7 +208,7 @@ def __call__( { "name": "--files-only", "action": "store_true", - "help": "Bump version in the files from the config (This is deprecated and will be removed in v5).", + "help": "Bump version in config files (deprecated; use --version-files-only).", }, { "name": "--version-files-only",