Skip to content

Commit 527c814

Browse files
2509abhibearomorphism
authored andcommitted
feat(bump): add --version-files-only and deprecate --files-only
1 parent 89f6b8f commit 527c814

9 files changed

+68
-31
lines changed

commitizen/cli.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,12 @@ def __call__(
209209
{
210210
"name": "--files-only", # TODO: rename to --version-files-only
211211
"action": "store_true",
212-
"help": "Bump version in the `version_files` specified in the configuration file only.",
212+
"help": "Bump version in the `version_files` specified in the configuration file only(deprecated; use --version-files-only instead).",
213+
},
214+
{
215+
"name": "--version-files-only",
216+
"action": "store_true",
217+
"help": "bump version in the files from the config",
213218
},
214219
{
215220
"name": "--local-version",

commitizen/commands/bump.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class BumpArgs(Settings, total=False):
4949
dry_run: bool
5050
file_name: str
5151
files_only: bool | None
52+
version_files_only: bool | None
5253
get_next: bool # TODO: maybe rename to `next_version_to_stdout`
5354
git_output_to_stderr: bool
5455
increment_mode: str
@@ -365,7 +366,14 @@ def __call__(self) -> None:
365366
changelog_file_name=changelog_file_name,
366367
)
367368

368-
if self.arguments["files_only"]:
369+
if self.arguments.get("files_only"):
370+
warnings.warn(
371+
"--files-only is deprecated and will be removed in v5. Use --version-files-only instead.",
372+
DeprecationWarning,
373+
)
374+
raise ExpectedExit()
375+
376+
if self.arguments.get("version_files_only"):
369377
raise ExpectedExit()
370378

371379
# FIXME: check if any changes have been staged

docs/commands/bump.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,12 @@ Commitizen supports the [PEP 440][pep440] version format, which includes several
109109

110110
![cz bump --help](../images/cli_help/cz_bump___help.svg)
111111

112-
### `--files-only`
112+
### `--version-files-only`
113113

114114
Bumps the version in the files defined in [`version_files`][version_files] without creating a commit and tag on the git repository.
115115

116116
```bash
117-
cz bump --files-only
117+
cz bump --version-files-only
118118
```
119119

120120
### `--changelog`

tests/commands/test_bump_command.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,8 @@ def test_bump_files_only(tmp_commitizen_project, util: UtilFixture):
418418

419419
util.create_file_and_commit("feat: another new feature")
420420
with pytest.raises(ExpectedExit):
421-
util.run_cli("bump", "--yes", "--files-only")
421+
util.run_cli("bump", "--yes", "--version-files-only")
422+
422423
assert git.tag_exist("0.3.0") is False
423424

424425
with open(tmp_version_file, encoding="utf-8") as f:
@@ -1175,7 +1176,7 @@ def test_bump_changelog_contains_increment_only(
11751176
# it should only include v3 changes
11761177
util.create_file_and_commit("feat(next)!: next version")
11771178
with pytest.raises(ExpectedExit):
1178-
util.run_cli("bump", "--yes", "--files-only", "--changelog-to-stdout")
1179+
util.run_cli("bump", "--yes", "--version-files-only", "--changelog-to-stdout")
11791180
out, _ = capsys.readouterr()
11801181

11811182
assert "3.0.0" in out
@@ -1463,3 +1464,11 @@ def test_changelog_config_flag_merge_prerelease_only_prerelease_present(
14631464
out = f.read()
14641465

14651466
file_regression.check(out, extension=".md")
1467+
1468+
1469+
@pytest.mark.usefixtures("tmp_commitizen_project")
1470+
def test_bump_deprecate_files_only(util: UtilFixture):
1471+
util.create_file_and_commit("feat: new file")
1472+
with pytest.warns(DeprecationWarning):
1473+
with pytest.raises(ExpectedExit):
1474+
util.run_cli("bump", "--yes", "--files-only")

tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_10_bump_.txt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
usage: cz bump [-h] [--dry-run] [--files-only] [--local-version] [--changelog]
2-
[--no-verify] [--yes] [--tag-format TAG_FORMAT]
3-
[--bump-message BUMP_MESSAGE] [--prerelease {alpha,beta,rc}]
4-
[--devrelease DEVRELEASE] [--increment {MAJOR,MINOR,PATCH}]
1+
usage: cz bump [-h] [--dry-run] [--files-only] [--version-files-only]
2+
[--local-version] [--changelog] [--no-verify] [--yes]
3+
[--tag-format TAG_FORMAT] [--bump-message BUMP_MESSAGE]
4+
[--prerelease {alpha,beta,rc}] [--devrelease DEVRELEASE]
5+
[--increment {MAJOR,MINOR,PATCH}]
56
[--increment-mode {linear,exact}] [--check-consistency]
67
[--annotated-tag]
78
[--annotated-tag-message ANNOTATED_TAG_MESSAGE] [--gpg-sign]
@@ -24,7 +25,9 @@ options:
2425
--dry-run Perform a dry run, without committing or modifying
2526
files.
2627
--files-only Bump version in the `version_files` specified in the
27-
configuration file only.
28+
configuration file only(deprecated; use --version-
29+
files-only instead).
30+
--version-files-only bump version in the files from the config
2831
--local-version Bump version only the local version portion (ignoring
2932
the public version).
3033
--changelog, -ch Generate the changelog for the latest version.

tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_11_bump_.txt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
usage: cz bump [-h] [--dry-run] [--files-only] [--local-version] [--changelog]
2-
[--no-verify] [--yes] [--tag-format TAG_FORMAT]
3-
[--bump-message BUMP_MESSAGE] [--prerelease {alpha,beta,rc}]
4-
[--devrelease DEVRELEASE] [--increment {MAJOR,MINOR,PATCH}]
1+
usage: cz bump [-h] [--dry-run] [--files-only] [--version-files-only]
2+
[--local-version] [--changelog] [--no-verify] [--yes]
3+
[--tag-format TAG_FORMAT] [--bump-message BUMP_MESSAGE]
4+
[--prerelease {alpha,beta,rc}] [--devrelease DEVRELEASE]
5+
[--increment {MAJOR,MINOR,PATCH}]
56
[--increment-mode {linear,exact}] [--check-consistency]
67
[--annotated-tag]
78
[--annotated-tag-message ANNOTATED_TAG_MESSAGE] [--gpg-sign]
@@ -24,7 +25,9 @@ options:
2425
--dry-run Perform a dry run, without committing or modifying
2526
files.
2627
--files-only Bump version in the `version_files` specified in the
27-
configuration file only.
28+
configuration file only(deprecated; use --version-
29+
files-only instead).
30+
--version-files-only bump version in the files from the config
2831
--local-version Bump version only the local version portion (ignoring
2932
the public version).
3033
--changelog, -ch Generate the changelog for the latest version.

tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_12_bump_.txt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
usage: cz bump [-h] [--dry-run] [--files-only] [--local-version] [--changelog]
2-
[--no-verify] [--yes] [--tag-format TAG_FORMAT]
3-
[--bump-message BUMP_MESSAGE] [--prerelease {alpha,beta,rc}]
4-
[--devrelease DEVRELEASE] [--increment {MAJOR,MINOR,PATCH}]
1+
usage: cz bump [-h] [--dry-run] [--files-only] [--version-files-only]
2+
[--local-version] [--changelog] [--no-verify] [--yes]
3+
[--tag-format TAG_FORMAT] [--bump-message BUMP_MESSAGE]
4+
[--prerelease {alpha,beta,rc}] [--devrelease DEVRELEASE]
5+
[--increment {MAJOR,MINOR,PATCH}]
56
[--increment-mode {linear,exact}] [--check-consistency]
67
[--annotated-tag]
78
[--annotated-tag-message ANNOTATED_TAG_MESSAGE] [--gpg-sign]
@@ -24,7 +25,9 @@ options:
2425
--dry-run Perform a dry run, without committing or modifying
2526
files.
2627
--files-only Bump version in the `version_files` specified in the
27-
configuration file only.
28+
configuration file only(deprecated; use --version-
29+
files-only instead).
30+
--version-files-only bump version in the files from the config
2831
--local-version Bump version only the local version portion (ignoring
2932
the public version).
3033
--changelog, -ch Generate the changelog for the latest version.

tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_13_bump_.txt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
usage: cz bump [-h] [--dry-run] [--files-only] [--local-version] [--changelog]
2-
[--no-verify] [--yes] [--tag-format TAG_FORMAT]
3-
[--bump-message BUMP_MESSAGE] [--prerelease {alpha,beta,rc}]
4-
[--devrelease DEVRELEASE] [--increment {MAJOR,MINOR,PATCH}]
1+
usage: cz bump [-h] [--dry-run] [--files-only] [--version-files-only]
2+
[--local-version] [--changelog] [--no-verify] [--yes]
3+
[--tag-format TAG_FORMAT] [--bump-message BUMP_MESSAGE]
4+
[--prerelease {alpha,beta,rc}] [--devrelease DEVRELEASE]
5+
[--increment {MAJOR,MINOR,PATCH}]
56
[--increment-mode {linear,exact}] [--check-consistency]
67
[--annotated-tag]
78
[--annotated-tag-message ANNOTATED_TAG_MESSAGE] [--gpg-sign]
@@ -24,7 +25,9 @@ options:
2425
--dry-run Perform a dry run, without committing or modifying
2526
files.
2627
--files-only Bump version in the `version_files` specified in the
27-
configuration file only.
28+
configuration file only(deprecated; use --version-
29+
files-only instead).
30+
--version-files-only bump version in the files from the config
2831
--local-version Bump version only the local version portion (ignoring
2932
the public version).
3033
--changelog, -ch Generate the changelog for the latest version.

tests/commands/test_common_command/test_command_shows_description_when_use_help_option_py_3_14_bump_.txt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
usage: cz bump [-h] [--dry-run] [--files-only] [--local-version] [--changelog]
2-
[--no-verify] [--yes] [--tag-format TAG_FORMAT]
3-
[--bump-message BUMP_MESSAGE] [--prerelease {alpha,beta,rc}]
4-
[--devrelease DEVRELEASE] [--increment {MAJOR,MINOR,PATCH}]
1+
usage: cz bump [-h] [--dry-run] [--files-only] [--version-files-only]
2+
[--local-version] [--changelog] [--no-verify] [--yes]
3+
[--tag-format TAG_FORMAT] [--bump-message BUMP_MESSAGE]
4+
[--prerelease {alpha,beta,rc}] [--devrelease DEVRELEASE]
5+
[--increment {MAJOR,MINOR,PATCH}]
56
[--increment-mode {linear,exact}] [--check-consistency]
67
[--annotated-tag]
78
[--annotated-tag-message ANNOTATED_TAG_MESSAGE] [--gpg-sign]
@@ -24,7 +25,9 @@ options:
2425
--dry-run Perform a dry run, without committing or modifying
2526
files.
2627
--files-only Bump version in the `version_files` specified in the
27-
configuration file only.
28+
configuration file only(deprecated; use --version-
29+
files-only instead).
30+
--version-files-only bump version in the files from the config
2831
--local-version Bump version only the local version portion (ignoring
2932
the public version).
3033
--changelog, -ch Generate the changelog for the latest version.

0 commit comments

Comments
 (0)