Skip to content

Commit

Permalink
feat: add shortcuts for docker run (stdout only)
Browse files Browse the repository at this point in the history
In order to allow more integration scenarios we allow bumping to stdout only without changing files.

docker run --rm bump-my-version patch 1.2.3
  • Loading branch information
reneleonhardt committed Nov 4, 2023
1 parent 7356a10 commit 78d0637
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
24 changes: 24 additions & 0 deletions bumpversion/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,30 @@ def show(args: List[str], config_file: Optional[str], format_: str, increment: O
do_show(*args, config=config, format_=format_, increment=increment)


@cli.command()
@click.argument("current_version", nargs=1, type=str)
def major(current_version: List[str]) -> None:
"""Bump current_version to next major version without changing files."""
conf = get_configuration(current_version=current_version)
do_show("new_version", config=conf, format_="default", increment="major")


@cli.command()
@click.argument("current_version", nargs=1, type=str)
def minor(current_version: List[str]) -> None:
"""Bump current_version to next minor version without changing files."""
conf = get_configuration(current_version=current_version)
do_show("new_version", config=conf, format_="default", increment="minor")


@cli.command()
@click.argument("current_version", nargs=1, type=str)
def patch(current_version: List[str]) -> None:
"""Bump current_version to next patch version without changing files."""
conf = get_configuration(current_version=current_version)
do_show("new_version", config=conf, format_="default", increment="patch")


@cli.command()
@click.argument("files", nargs=-1, type=str)
@click.option(
Expand Down
48 changes: 48 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,54 @@ def test_show(tmp_path: Path, fixtures_path: Path):
assert result.output.splitlines(keepends=False) == ["1.0.0"]


def test_major(tmp_path: Path):
"""The major subcommand should bump the given value to the next major version."""
# Arrange
runner: CliRunner = CliRunner()

with inside_dir(tmp_path):
result: Result = runner.invoke(cli.cli, ["major", "v0.1.2"])

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

assert result.exit_code == 0
assert result.output.splitlines(keepends=False) == ["1.0.0"]


def test_minor(tmp_path: Path):
"""The minor subcommand should bump the given value to the next minor version."""
# Arrange
runner: CliRunner = CliRunner()

with inside_dir(tmp_path):
result: Result = runner.invoke(cli.cli, ["minor", "v0.0.2"])

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

assert result.exit_code == 0
assert result.output.splitlines(keepends=False) == ["0.1.0"]


def test_patch(tmp_path: Path):
"""The patch subcommand should bump the given value to the next patch version."""
# Arrange
runner: CliRunner = CliRunner()

with inside_dir(tmp_path):
result: Result = runner.invoke(cli.cli, ["patch", "v1.2.3"])

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

assert result.exit_code == 0
assert result.output.splitlines(keepends=False) == ["1.2.4"]


def test_show_and_increment(tmp_path: Path, fixtures_path: Path):
"""The show subcommand should incrment the version and display it."""
# Arrange
Expand Down

0 comments on commit 78d0637

Please sign in to comment.