Skip to content

Commit 0fd770e

Browse files
committed
feat(bump): add --version-files-only and deprecate --files-only
1 parent cbbf615 commit 0fd770e

File tree

5 files changed

+31
-6
lines changed

5 files changed

+31
-6
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 the files from the config (This is deprecated and will be removed in v5).",
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: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class BumpArgs(Settings, total=False):
4747
dry_run: bool
4848
file_name: str
4949
files_only: bool | None
50+
version_files_only: bool | None
5051
get_next: bool
5152
git_output_to_stderr: bool
5253
increment_mode: str
@@ -356,9 +357,17 @@ def __call__(self) -> None:
356357
else None,
357358
)
358359

359-
if self.arguments["files_only"]:
360+
if self.arguments.get("files_only"):
361+
warnings.warn(
362+
"--files-only is deprecated and will be removed in v5. Use --version-files-only instead.",
363+
DeprecationWarning,
364+
)
360365
raise ExpectedExit()
361366

367+
if self.arguments.get("version_files_only"):
368+
raise ExpectedExit()
369+
370+
362371
# FIXME: check if any changes have been staged
363372
git.add(*files)
364373
c = git.commit(message, args=self._get_commit_args())

docs/commands/bump.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,24 @@ 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+
### `--files-only` (deprecated)
113+
**Deprecated**: This flag will be removed in Commitizen v5.
114+
Please use [`--version-files-only`](#--version-files-only) instead.
113115

114116
Bumps the version in the files defined in [`version_files`](#version_files) without creating a commit and tag on the git repository,
115117

116118
```bash
117119
cz bump --files-only
118120
```
119121

122+
### `--version-files-only`
123+
124+
Bumps the version in the files defined in [`version_files`](#version_files) without creating a commit and tag on the git repository,
125+
126+
```bash
127+
cz bump --version-files-only
128+
```
129+
120130
### `--changelog`
121131

122132
Generate a **changelog** along with the new version and tag when bumping. See [changelog](./changelog.md) for more details.

tests/commands/test_bump_command.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ def test_bump_files_only(mocker: MockFixture, tmp_commitizen_project):
555555
assert tag_exists is True
556556

557557
create_file_and_commit("feat: another new feature")
558-
testargs = ["cz", "bump", "--yes", "--files-only"]
558+
testargs = ["cz", "bump", "--yes", "--files-only","--version-files-only"]
559559
mocker.patch.object(sys, "argv", testargs)
560560
with pytest.raises(ExpectedExit):
561561
cli.main()
@@ -1427,7 +1427,7 @@ def test_bump_changelog_contains_increment_only(mocker, tmp_commitizen_project,
14271427
# Add a commit and create the incremental changelog to v3.0.0
14281428
# it should only include v3 changes
14291429
create_file_and_commit("feat(next)!: next version")
1430-
testargs = ["cz", "bump", "--yes", "--files-only", "--changelog-to-stdout"]
1430+
testargs = ["cz", "bump", "--yes", "--files-only", "--version-files-only", "--changelog-to-stdout"]
14311431
mocker.patch.object(sys, "argv", testargs)
14321432
with pytest.raises(ExpectedExit):
14331433
cli.main()

tests/commands/test_bump_command/test_bump_command_shows_description_when_use_help_option.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
usage: cz bump [-h] [--dry-run] [--files-only] [--local-version] [--changelog]
1+
usage: cz bump [-h] [--dry-run] [--files-only] [--version-files-only] [--local-version] [--changelog]
22
[--no-verify] [--yes] [--tag-format TAG_FORMAT]
33
[--bump-message BUMP_MESSAGE] [--prerelease {alpha,beta,rc}]
44
[--devrelease DEVRELEASE] [--increment {MAJOR,MINOR,PATCH}]
@@ -22,7 +22,8 @@ positional arguments:
2222
options:
2323
-h, --help show this help message and exit
2424
--dry-run show output to stdout, no commit, no modified files
25-
--files-only bump version in the files from the config
25+
--files-only bump version in the files from the config (Deprecated in v5)
26+
--version-files-only bump version in the files from the config
2627
--local-version bump only the local version portion
2728
--changelog, -ch generate the changelog for the newest version
2829
--no-verify this option bypasses the pre-commit and commit-msg

0 commit comments

Comments
 (0)