Skip to content

Commit

Permalink
Merge pull request #151 from callowayproject/remove-non-subcommand
Browse files Browse the repository at this point in the history
Removes ability to call the CLI without subcommand
  • Loading branch information
coordt authored Mar 12, 2024
2 parents e13b0f0 + ae1732b commit cc444b1
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 181 deletions.
6 changes: 6 additions & 0 deletions .changelog-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ ignore_patterns:

# Set the commit's category metadata to the first classifier that returns ``True``.
commit_classifiers:
- action: MetadataMatch
category: Breaking Changes
kwargs:
attribute: has_breaking_change
operator: is
value: True
- action: SummaryRegexMatch
category: New
kwargs:
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## Unreleased (2024-03-12)
[Compare the full difference.](https://github.com/callowayproject/bump-my-version/compare/0.18.3...HEAD)

### Updates

- Removes ability to call the CLI without subcommand. [e56c944](https://github.com/callowayproject/bump-my-version/commit/e56c944699151d589cec2b16a52f15cf56d151e6)

BREAKING CHANGE: You must use bump-my-version bump

## 0.18.3 (2024-02-25)
[Compare the full difference.](https://github.com/callowayproject/bump-my-version/compare/0.18.2...0.18.3)

Expand Down
22 changes: 3 additions & 19 deletions bumpversion/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,20 @@
from tomlkit import dumps

from bumpversion import __version__
from bumpversion.aliases import AliasedGroup
from bumpversion.bump import do_bump
from bumpversion.config import get_configuration
from bumpversion.config.create import create_configuration
from bumpversion.config.files import find_config_file
from bumpversion.files import ConfiguredFile, modify_files
from bumpversion.show import do_show, log_list
from bumpversion.ui import get_indented_logger, print_info, print_warning, setup_logging
from bumpversion.show import do_show
from bumpversion.ui import get_indented_logger, print_info, setup_logging
from bumpversion.utils import get_context, get_overrides
from bumpversion.visualize import visualize

logger = get_indented_logger(__name__)


@click.group(
cls=AliasedGroup,
invoke_without_command=True,
context_settings={
"ignore_unknown_options": True,
"allow_interspersed_args": True,
Expand All @@ -37,8 +34,7 @@
@click.pass_context
def cli(ctx: Context) -> None:
"""Version bump your Python project."""
if ctx.invoked_subcommand is None:
ctx.invoke(bump, *ctx.args)
pass


click.rich_click.OPTION_GROUPS = {
Expand Down Expand Up @@ -228,12 +224,6 @@ def cli(ctx: Context) -> None:
envvar="BUMPVERSION_COMMIT_ARGS",
help="Extra arguments to commit command",
)
@click.option(
"--list",
"show_list",
is_flag=True,
help="List machine readable information",
)
def bump(
# version_part: str,
args: list,
Expand All @@ -258,7 +248,6 @@ def bump(
tag_message: Optional[str],
message: Optional[str],
commit_args: Optional[str],
show_list: bool,
) -> None:
"""
Change the version.
Expand Down Expand Up @@ -306,11 +295,6 @@ def bump(
version_part = None
files = args

if show_list:
print_warning("DEPRECATED: The --list option is deprecated and will be removed in a future version.")
log_list(config, version_part, new_version)
return

config.allow_dirty = allow_dirty if allow_dirty is not None else config.allow_dirty
if not config.allow_dirty and config.scm_info.tool:
config.scm_info.tool.assert_nondirty()
Expand Down
15 changes: 0 additions & 15 deletions bumpversion/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,21 +108,6 @@ def resolve_name(obj: Any, name: str, default: Any = None, err_on_missing: bool
return default


def log_list(config: Config, version_part: Optional[str], new_version: Optional[str]) -> None:
"""Output configuration with new version."""
ctx = get_context(config)
if version_part:
version = config.version_config.parse(config.current_version)
next_version = get_next_version(version, config, version_part, new_version)
next_version_str = config.version_config.serialize(next_version, ctx)

print_info(f"new_version={next_version_str}")

config_dict = recursive_sort_dict(config.model_dump(exclude={"scm_info", "parts"}))
for key, value in config_dict.items():
print_info(f"{key}={value}")


def do_show(*args, config: Config, format_: str = "default", increment: Optional[str] = None) -> None:
"""Show current version or configuration information."""
config_dict = config.model_dump()
Expand Down
125 changes: 0 additions & 125 deletions tests/test_cli/test_bump.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,131 +59,6 @@ def test_file_args_marked_to_modify(self, mocker, tmp_path: Path):
assert passed_config.files[0].filename == "do-this-file.txt"


class TestListOption:
"""Test the deprecated --list option."""

def test_with_version_part_includes_new_version(self, tmp_path: Path, fixtures_path: Path):
"""The --list option should list the configuration with new_version."""
# Arrange
config_path = tmp_path / "pyproject.toml"
toml_path = fixtures_path / "basic_cfg.toml"
shutil.copy(toml_path, config_path)
runner: CliRunner = CliRunner()

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

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

assert result.exit_code == 0
assert set(result.output.splitlines(keepends=False)) == {
"WARNING:",
"",
"DEPRECATED: The --list option is deprecated and will be removed in a future version.",
"new_version=1.0.1-dev",
"current_version=1.0.0",
"excluded_paths=[]",
"parse=(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)(\\-(?P<release>[a-z]+))?",
"serialize=('{major}.{minor}.{patch}-{release}', '{major}.{minor}.{patch}')",
"search={current_version}",
"replace={new_version}",
"regex=False",
"ignore_missing_files=False",
"ignore_missing_version=False",
"included_paths=[]",
"tag=True",
"sign_tags=False",
"tag_name=v{new_version}",
"tag_message=Bump version: {current_version} → {new_version}",
"allow_dirty=False",
"commit=True",
"message=Bump version: {current_version} → {new_version}",
"commit_args=None",
(
"files=[{'parse': "
"'(?P<major>\\\\d+)\\\\.(?P<minor>\\\\d+)\\\\.(?P<patch>\\\\d+)(\\\\-(?P<release>[a-z]+))?', "
"'serialize': ('{major}.{minor}.{patch}-{release}', "
"'{major}.{minor}.{patch}'), 'search': '{current_version}', 'replace': "
"'{new_version}', 'regex': False, 'ignore_missing_version': False, "
"'ignore_missing_file': False, 'filename': 'setup.py', 'glob': None, 'key_path': None}, {'parse': "
"'(?P<major>\\\\d+)\\\\.(?P<minor>\\\\d+)\\\\.(?P<patch>\\\\d+)(\\\\-(?P<release>[a-z]+))?', "
"'serialize': ('{major}.{minor}.{patch}-{release}', "
"'{major}.{minor}.{patch}'), 'search': '{current_version}', 'replace': "
"'{new_version}', 'regex': False, 'ignore_missing_version': False, "
"'ignore_missing_file': False, 'filename': 'bumpversion/__init__.py', 'glob': None, 'key_path': None}, "
"{'parse': "
"'(?P<major>\\\\d+)\\\\.(?P<minor>\\\\d+)\\\\.(?P<patch>\\\\d+)(\\\\-(?P<release>[a-z]+))?', "
"'serialize': ('{major}.{minor}.{patch}-{release}', "
"'{major}.{minor}.{patch}'), 'search': '**unreleased**', 'replace': "
"'**unreleased**\\n**v{new_version}**', 'regex': False, "
"'ignore_missing_version': False, 'ignore_missing_file': False, 'filename': 'CHANGELOG.md', "
"'glob': None, 'key_path': None}]"
),
}

def test_without_version_part_excludes_new_version(self, tmp_path: Path, fixtures_path: Path):
"""The --list option should list the configuration without new_version."""
# Arrange
config_path = tmp_path / "pyproject.toml"
toml_path = fixtures_path / "basic_cfg.toml"
shutil.copy(toml_path, config_path)
runner: CliRunner = CliRunner()

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

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

assert result.exit_code == 0
assert set(result.output.splitlines(keepends=False)) == {
"WARNING:",
"",
"DEPRECATED: The --list option is deprecated and will be removed in a future version.",
"current_version=1.0.0",
"excluded_paths=[]",
"parse=(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)(\\-(?P<release>[a-z]+))?",
"serialize=('{major}.{minor}.{patch}-{release}', '{major}.{minor}.{patch}')",
"search={current_version}",
"replace={new_version}",
"regex=False",
"ignore_missing_files=False",
"ignore_missing_version=False",
"included_paths=[]",
"tag=True",
"sign_tags=False",
"tag_name=v{new_version}",
"tag_message=Bump version: {current_version} → {new_version}",
"allow_dirty=False",
"commit=True",
"message=Bump version: {current_version} → {new_version}",
"commit_args=None",
(
"files=[{'parse': "
"'(?P<major>\\\\d+)\\\\.(?P<minor>\\\\d+)\\\\.(?P<patch>\\\\d+)(\\\\-(?P<release>[a-z]+))?', "
"'serialize': ('{major}.{minor}.{patch}-{release}', "
"'{major}.{minor}.{patch}'), 'search': '{current_version}', 'replace': "
"'{new_version}', 'regex': False, 'ignore_missing_version': False, "
"'ignore_missing_file': False, 'filename': 'setup.py', 'glob': None, 'key_path': None}, {'parse': "
"'(?P<major>\\\\d+)\\\\.(?P<minor>\\\\d+)\\\\.(?P<patch>\\\\d+)(\\\\-(?P<release>[a-z]+))?', "
"'serialize': ('{major}.{minor}.{patch}-{release}', "
"'{major}.{minor}.{patch}'), 'search': '{current_version}', 'replace': "
"'{new_version}', 'regex': False, 'ignore_missing_version': False, "
"'ignore_missing_file': False, 'filename': 'bumpversion/__init__.py', 'glob': None, 'key_path': None}, "
"{'parse': "
"'(?P<major>\\\\d+)\\\\.(?P<minor>\\\\d+)\\\\.(?P<patch>\\\\d+)(\\\\-(?P<release>[a-z]+))?', "
"'serialize': ('{major}.{minor}.{patch}-{release}', "
"'{major}.{minor}.{patch}'), 'search': '**unreleased**', 'replace': "
"'**unreleased**\\n**v{new_version}**', 'regex': False, "
"'ignore_missing_version': False, 'ignore_missing_file': False, 'filename': 'CHANGELOG.md', "
"'glob': None, 'key_path': None}]"
),
}


def test_bump_nested_regex(tmp_path: Path, fixtures_path: Path, caplog):
"""
Arrange/Act: Run the `bump` subcommand with --no-configured-files.
Expand Down
22 changes: 0 additions & 22 deletions tests/test_cli/test_legacy.py

This file was deleted.

0 comments on commit cc444b1

Please sign in to comment.