Skip to content

Commit

Permalink
Fixed --help and bump invocations
Browse files Browse the repository at this point in the history
- `--help` works for individual sub-commands, but not for the command
- `bump` now works and fixed tests
  • Loading branch information
coordt committed Jun 22, 2023
1 parent d537274 commit 9d965e5
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 9 deletions.
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
# Changelog

## Unreleased (2023-06-21)
[Compare the full difference.](https://github.com/callowayproject/bump-my-version/compare/0.5.1...HEAD)

### Fixes

- Fixed issue regarding TOML types. [8960d24](https://github.com/callowayproject/bump-my-version/commit/8960d249183cf78d8b35967b86fef8701fc9c37e)

- `tomlkit.parse()` returns a `TOMLDocument`.
- `unwrap()` converts it into a `dict`
### New

- Added documentation for the show command. [d537274](https://github.com/callowayproject/bump-my-version/commit/d5372742a8cf76777f1bf4450bf31e9310d04681)

- Adds `--increment` option to `show` subcommand. [b01fffc](https://github.com/callowayproject/bump-my-version/commit/b01fffcad8479db25375d53fdeebc879d7317b11)

- when specified it increments the current version and adds `new_version` to the available output.
- Added `show` subcommand. [9bce887](https://github.com/callowayproject/bump-my-version/commit/9bce887cf5e72907ae00b45a7b7f4812dcc2f17e)

- supersedes the `--list` option
- provides much more capability
- Can output in YAML, JSON, and default
- Can specify one or more items to display
- Can use dotted-notation to pull items from nested data structures.
### Updates

- Changes bump-my-version into subcommands. [31ffbcf](https://github.com/callowayproject/bump-my-version/commit/31ffbcf839e2491c31d90b51041d1e840371108f)

- Is backwards-compatible with previous versions
- `bump-my-version` forwards command to `bump-my-version bump` subcommand
- Only problem is that Click will not show help automatically, must provide `--help`

## 0.5.1 (2023-06-14)
[Compare the full difference.](https://github.com/callowayproject/bump-my-version/compare/0.5.0...0.5.1)

Expand Down
2 changes: 1 addition & 1 deletion bumpversion/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Top-level package for bump-my-version."""

__version__: str = "0.5.1"
__version__: str = "0.5.1.dev6"
3 changes: 3 additions & 0 deletions bumpversion/aliases.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ def resolve_command(self, ctx: Context, args: List[str]) -> tuple:
# always return the full command name
original_args = args[:]
_, cmd, args = super().resolve_command(ctx, args)

if cmd.name == "bump" and args != original_args:
if "bump" in original_args:
original_args.remove("bump")
return cmd.name, cmd, original_args
return cmd.name, cmd, args
1 change: 1 addition & 0 deletions bumpversion/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"ignore_unknown_options": True,
"allow_interspersed_args": True,
},
add_help_option=False,
)
@click.version_option(version=__version__)
@click.pass_context
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ order-by-type = true
convention = "google"

[tool.bumpversion]
current_version = "0.5.1"
current_version = "0.5.1.dev6"
commit = true
commit_args = "--no-verify"
tag = true
Expand Down
39 changes: 32 additions & 7 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,28 @@ def test_bump_no_configured_files(mocker, tmp_path):
"""
Arrange/Act: Run the `bump` subcommand with --no-configured-files.
Assert: There is no configured files specified to modify
"""
mocked_do_bump = mocker.patch("bumpversion.cli.do_bump")
runner: CliRunner = CliRunner()
with inside_dir(tmp_path):
result: Result = runner.invoke(
cli.cli, ["bump", "--current-version", "1.0.0", "--no-configured-files", "patch"]
)

if result.exit_code != 0:
print(result.output)

assert result.exit_code == 0

call_args = mocked_do_bump.call_args[0]
assert len(call_args[2].files) == 0


def test_bump_legacy(mocker, tmp_path):
"""
Arrange/Act: Run the `bump` subcommand with --no-configured-files.
Assert: There is no configured files specified to modify
"""
mocked_do_bump = mocker.patch("bumpversion.cli.do_bump")
Expand All @@ -47,7 +69,7 @@ def test_no_configured_files_still_file_args_work(mocker, tmp_path):
runner: CliRunner = CliRunner()
with inside_dir(tmp_path):
result: Result = runner.invoke(
cli.cli, ["--current-version", "1.0.0", "--no-configured-files", "patch", "do-this-file.txt"]
cli.cli, ["bump", "--current-version", "1.0.0", "--no-configured-files", "patch", "do-this-file.txt"]
)

if result.exit_code != 0:
Expand All @@ -65,7 +87,7 @@ def test_missing_explicit_config_file(tmp_path: Path):
with inside_dir(tmp_path):
runner: CliRunner = CliRunner()
with inside_dir(tmp_path):
result: Result = runner.invoke(cli.cli, ["--config-file", "missing-file.cfg"])
result: Result = runner.invoke(cli.cli, ["bump", "--config-file", "missing-file.cfg"])
assert result.exit_code != 0
assert "'missing-file.cfg' does not exist." in result.output

Expand All @@ -84,6 +106,7 @@ def test_cli_options_override_config(tmp_path: Path, fixtures_path: Path, mocker
result: Result = runner.invoke(
cli.cli,
[
"bump",
"--config-file",
str(config_path),
"--current-version",
Expand Down Expand Up @@ -146,7 +169,9 @@ def test_dirty_work_dir_raises_error(repo: str, scm_command: str, request):
runner: CliRunner = CliRunner()

# Act
result: Result = runner.invoke(cli.cli, ["patch", "--current-version", "1.1.1", "--no-allow-dirty", "dirty2"])
result: Result = runner.invoke(
cli.cli, ["bump", "patch", "--current-version", "1.1.1", "--no-allow-dirty", "dirty2"]
)

# Assert
assert result.exit_code != 0
Expand All @@ -162,7 +187,7 @@ def test_listing_with_version_part(tmp_path: Path, fixtures_path: Path):
runner: CliRunner = CliRunner()

with inside_dir(tmp_path):
result: Result = runner.invoke(cli.cli, ["--list", "patch"])
result: Result = runner.invoke(cli.cli, ["bump", "--list", "patch"])

if result.exit_code != 0:
print(result.output)
Expand Down Expand Up @@ -202,7 +227,7 @@ def test_listing_without_version_part(tmp_path: Path, fixtures_path: Path):
runner: CliRunner = CliRunner()

with inside_dir(tmp_path):
result: Result = runner.invoke(cli.cli, ["--list"])
result: Result = runner.invoke(cli.cli, ["bump", "--list"])

if result.exit_code != 0:
print(result.output)
Expand Down Expand Up @@ -244,7 +269,7 @@ def test_non_scm_operations_if_scm_not_installed(tmp_path: Path, monkeypatch):
runner: CliRunner = CliRunner()

# Act
runner.invoke(cli.cli, ["major", "--current-version", "31.0.3", "VERSION"])
runner.invoke(cli.cli, ["bump", "major", "--current-version", "31.0.3", "VERSION"])

# Assert
assert version_path.read_text() == "32.0.0"
Expand All @@ -267,7 +292,7 @@ def test_detects_bad_or_missing_version_part(version_part: str, tmp_path: Path,
version_path.write_text("31.0.3")

runner: CliRunner = CliRunner()
args = ["--current-version", "31.0.3"]
args = ["bump", "--current-version", "31.0.3"]
if version_part:
args.append(version_part)
args.append("VERSION")
Expand Down

0 comments on commit 9d965e5

Please sign in to comment.