From e56c944699151d589cec2b16a52f15cf56d151e6 Mon Sep 17 00:00:00 2001 From: Corey Oordt Date: Tue, 12 Mar 2024 09:42:58 -0500 Subject: [PATCH 1/2] Removes ability to call the CLI without subcommand BREAKING CHANGE: You must use bump-my-version bump --- bumpversion/cli.py | 22 +----- bumpversion/show.py | 15 ---- tests/test_cli/test_bump.py | 125 ---------------------------------- tests/test_cli/test_legacy.py | 22 ------ 4 files changed, 3 insertions(+), 181 deletions(-) delete mode 100644 tests/test_cli/test_legacy.py diff --git a/bumpversion/cli.py b/bumpversion/cli.py index daee9878..cd14f726 100644 --- a/bumpversion/cli.py +++ b/bumpversion/cli.py @@ -9,14 +9,13 @@ 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 @@ -24,8 +23,6 @@ @click.group( - cls=AliasedGroup, - invoke_without_command=True, context_settings={ "ignore_unknown_options": True, "allow_interspersed_args": True, @@ -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 = { @@ -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, @@ -258,7 +248,6 @@ def bump( tag_message: Optional[str], message: Optional[str], commit_args: Optional[str], - show_list: bool, ) -> None: """ Change the version. @@ -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() diff --git a/bumpversion/show.py b/bumpversion/show.py index 3107334f..439acf66 100644 --- a/bumpversion/show.py +++ b/bumpversion/show.py @@ -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() diff --git a/tests/test_cli/test_bump.py b/tests/test_cli/test_bump.py index cc658212..e6df7a5c 100644 --- a/tests/test_cli/test_bump.py +++ b/tests/test_cli/test_bump.py @@ -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\\d+)\\.(?P\\d+)\\.(?P\\d+)(\\-(?P[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\\\\d+)\\\\.(?P\\\\d+)\\\\.(?P\\\\d+)(\\\\-(?P[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\\\\d+)\\\\.(?P\\\\d+)\\\\.(?P\\\\d+)(\\\\-(?P[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\\\\d+)\\\\.(?P\\\\d+)\\\\.(?P\\\\d+)(\\\\-(?P[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\\d+)\\.(?P\\d+)\\.(?P\\d+)(\\-(?P[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\\\\d+)\\\\.(?P\\\\d+)\\\\.(?P\\\\d+)(\\\\-(?P[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\\\\d+)\\\\.(?P\\\\d+)\\\\.(?P\\\\d+)(\\\\-(?P[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\\\\d+)\\\\.(?P\\\\d+)\\\\.(?P\\\\d+)(\\\\-(?P[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. diff --git a/tests/test_cli/test_legacy.py b/tests/test_cli/test_legacy.py deleted file mode 100644 index 8427dfe4..00000000 --- a/tests/test_cli/test_legacy.py +++ /dev/null @@ -1,22 +0,0 @@ -from click.testing import CliRunner, Result - -from bumpversion import cli -from tests.conftest import inside_dir - - -def test_no_subcommand_calls_bump(mocker, tmp_path): - """ - The legacy behavior of calling `bumpversion` with no subcommand is to call `bump`. - """ - mocked_do_bump = mocker.patch("bumpversion.cli.do_bump") - runner: CliRunner = CliRunner() - with inside_dir(tmp_path): - result: Result = runner.invoke(cli.cli, ["--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 From ae1732b4a9b543992f83677263bb242c49c0f5c5 Mon Sep 17 00:00:00 2001 From: Corey Oordt Date: Tue, 12 Mar 2024 09:57:01 -0500 Subject: [PATCH 2/2] Fixing version hint generation --- .changelog-config.yaml | 6 ++++++ CHANGELOG.md | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/.changelog-config.yaml b/.changelog-config.yaml index 94e3b9dd..1f88f5fb 100644 --- a/.changelog-config.yaml +++ b/.changelog-config.yaml @@ -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: diff --git a/CHANGELOG.md b/CHANGELOG.md index 35efe1c0..632661ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)