Skip to content

Commit b5e7cdb

Browse files
2509abhibearomorphism
authored andcommitted
feat(bump): add --version-files-only and deprecate --files-only
1 parent 8283081 commit b5e7cdb

9 files changed

+66
-30
lines changed

commitizen/cli.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,11 @@ def __call__(
208208
{
209209
"name": "--files-only",
210210
"action": "store_true",
211+
"help": "Bump version in config files (deprecated; use --version-files-only instead).",
212+
},
213+
{
214+
"name": "--version-files-only",
215+
"action": "store_true",
211216
"help": "bump version in the files from the config",
212217
},
213218
{

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
@@ -366,7 +367,14 @@ def __call__(self) -> None:
366367
else None,
367368
)
368369

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

372380
# 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: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ def test_bump_files_only(tmp_commitizen_project, util: UtilFixture):
470470

471471
util.create_file_and_commit("feat: another new feature")
472472
with pytest.raises(ExpectedExit):
473-
util.run_cli("bump", "--yes", "--files-only")
473+
util.run_cli("bump", "--yes", "--version-files-only")
474474

475475
tag_exists = git.tag_exist("0.3.0")
476476
assert tag_exists is False
@@ -1267,7 +1267,7 @@ def test_bump_changelog_contains_increment_only(
12671267
# it should only include v3 changes
12681268
util.create_file_and_commit("feat(next)!: next version")
12691269
with pytest.raises(ExpectedExit):
1270-
util.run_cli("bump", "--yes", "--files-only", "--changelog-to-stdout")
1270+
util.run_cli("bump", "--yes", "--version-files-only", "--changelog-to-stdout")
12711271
out, _ = capsys.readouterr()
12721272

12731273
assert "3.0.0" in out
@@ -1557,3 +1557,11 @@ def test_changelog_config_flag_merge_prerelease_only_prerelease_present(
15571557
out = f.read()
15581558

15591559
file_regression.check(out, extension=".md")
1560+
1561+
1562+
@pytest.mark.usefixtures("tmp_commitizen_project")
1563+
def test_bump_deprecate_files_only(util: UtilFixture):
1564+
util.create_file_and_commit("feat: new file")
1565+
with pytest.warns(DeprecationWarning):
1566+
with pytest.raises(ExpectedExit):
1567+
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]
@@ -22,7 +23,9 @@ positional arguments:
2223
options:
2324
-h, --help show this help message and exit
2425
--dry-run show output to stdout, no commit, no modified files
25-
--files-only bump version in the files from the config
26+
--files-only Bump version in config files (deprecated; use
27+
--version-files-only instead).
28+
--version-files-only bump version in the files from the config
2629
--local-version bump only the local version portion
2730
--changelog, -ch generate the changelog for the newest version
2831
--no-verify this option bypasses the pre-commit and commit-msg

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]
@@ -22,7 +23,9 @@ positional arguments:
2223
options:
2324
-h, --help show this help message and exit
2425
--dry-run show output to stdout, no commit, no modified files
25-
--files-only bump version in the files from the config
26+
--files-only Bump version in config files (deprecated; use
27+
--version-files-only instead).
28+
--version-files-only bump version in the files from the config
2629
--local-version bump only the local version portion
2730
--changelog, -ch generate the changelog for the newest version
2831
--no-verify this option bypasses the pre-commit and commit-msg

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]
@@ -22,7 +23,9 @@ positional arguments:
2223
options:
2324
-h, --help show this help message and exit
2425
--dry-run show output to stdout, no commit, no modified files
25-
--files-only bump version in the files from the config
26+
--files-only Bump version in config files (deprecated; use
27+
--version-files-only instead).
28+
--version-files-only bump version in the files from the config
2629
--local-version bump only the local version portion
2730
--changelog, -ch generate the changelog for the newest version
2831
--no-verify this option bypasses the pre-commit and commit-msg

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]
@@ -22,7 +23,9 @@ positional arguments:
2223
options:
2324
-h, --help show this help message and exit
2425
--dry-run show output to stdout, no commit, no modified files
25-
--files-only bump version in the files from the config
26+
--files-only Bump version in config files (deprecated; use
27+
--version-files-only instead).
28+
--version-files-only bump version in the files from the config
2629
--local-version bump only the local version portion
2730
--changelog, -ch generate the changelog for the newest version
2831
--no-verify this option bypasses the pre-commit and commit-msg

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]
@@ -22,7 +23,9 @@ positional arguments:
2223
options:
2324
-h, --help show this help message and exit
2425
--dry-run show output to stdout, no commit, no modified files
25-
--files-only bump version in the files from the config
26+
--files-only Bump version in config files (deprecated; use
27+
--version-files-only instead).
28+
--version-files-only bump version in the files from the config
2629
--local-version bump only the local version portion
2730
--changelog, -ch generate the changelog for the newest version
2831
--no-verify this option bypasses the pre-commit and commit-msg

0 commit comments

Comments
 (0)