Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions commitizen/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
{
Expand Down
11 changes: 10 additions & 1 deletion commitizen/commands/bump.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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())
Expand Down
12 changes: 11 additions & 1 deletion docs/commands/bump.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,24 @@ 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,

```bash
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.
Expand Down
4 changes: 2 additions & 2 deletions tests/commands/test_bump_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
testargs = ["cz", "bump", "--yes", "--files-only","--version-files-only"]
testargs = ["cz", "bump", "--yes", "--files-only", "--version-files-only"]

Copy link
Member

Choose a reason for hiding this comment

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

I think we should also have --version-files-only cases

mocker.patch.object(sys, "argv", testargs)
with pytest.raises(ExpectedExit):
cli.main()
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
@@ -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}]
Expand All @@ -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
Expand Down
Loading