Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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 config files (deprecated; use --version-files-only instead).",
},
{
"name": "--version-files-only",
"action": "store_true",
"help": "bump version in the files from the config",
},
{
Expand Down
10 changes: 9 additions & 1 deletion commitizen/commands/bump.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class BumpArgs(Settings, total=False):
dry_run: bool
file_name: str
files_only: bool | None
version_files_only: bool | None
get_next: bool # TODO: maybe rename to `next_version_to_stdout`
git_output_to_stderr: bool
increment_mode: str
Expand Down Expand Up @@ -366,7 +367,14 @@ 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
Expand Down
4 changes: 2 additions & 2 deletions docs/commands/bump.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ Commitizen supports the [PEP 440][pep440] version format, which includes several

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

### `--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 --files-only
cz bump --version-files-only
```

### `--changelog`
Expand Down
12 changes: 10 additions & 2 deletions tests/commands/test_bump_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ def test_bump_files_only(tmp_commitizen_project, util: UtilFixture):

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

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

assert "3.0.0" in out
Expand Down Expand Up @@ -1557,3 +1557,11 @@ def test_changelog_config_flag_merge_prerelease_only_prerelease_present(
out = f.read()

file_regression.check(out, extension=".md")


@pytest.mark.usefixtures("tmp_commitizen_project")
def test_bump_deprecate_files_only(util: UtilFixture):
util.create_file_and_commit("feat: new file")
with pytest.warns(DeprecationWarning):
with pytest.raises(ExpectedExit):
util.run_cli("bump", "--yes", "--files-only")
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
usage: cz bump [-h] [--dry-run] [--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}]
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}]
[--increment-mode {linear,exact}] [--check-consistency]
[--annotated-tag]
[--annotated-tag-message ANNOTATED_TAG_MESSAGE] [--gpg-sign]
Expand All @@ -22,7 +23,9 @@ 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 config files (deprecated; use
--version-files-only instead).
--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
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
usage: cz bump [-h] [--dry-run] [--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}]
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}]
[--increment-mode {linear,exact}] [--check-consistency]
[--annotated-tag]
[--annotated-tag-message ANNOTATED_TAG_MESSAGE] [--gpg-sign]
Expand All @@ -22,7 +23,9 @@ 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 config files (deprecated; use
--version-files-only instead).
--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
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
usage: cz bump [-h] [--dry-run] [--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}]
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}]
[--increment-mode {linear,exact}] [--check-consistency]
[--annotated-tag]
[--annotated-tag-message ANNOTATED_TAG_MESSAGE] [--gpg-sign]
Expand All @@ -22,7 +23,9 @@ 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 config files (deprecated; use
--version-files-only instead).
--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
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
usage: cz bump [-h] [--dry-run] [--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}]
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}]
[--increment-mode {linear,exact}] [--check-consistency]
[--annotated-tag]
[--annotated-tag-message ANNOTATED_TAG_MESSAGE] [--gpg-sign]
Expand All @@ -22,7 +23,9 @@ 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 config files (deprecated; use
--version-files-only instead).
--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
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
usage: cz bump [-h] [--dry-run] [--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}]
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}]
[--increment-mode {linear,exact}] [--check-consistency]
[--annotated-tag]
[--annotated-tag-message ANNOTATED_TAG_MESSAGE] [--gpg-sign]
Expand All @@ -22,7 +23,9 @@ 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 config files (deprecated; use
--version-files-only instead).
--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