From e56c944699151d589cec2b16a52f15cf56d151e6 Mon Sep 17 00:00:00 2001 From: Corey Oordt Date: Tue, 12 Mar 2024 09:42:58 -0500 Subject: [PATCH 1/4] 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/4] 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) From c38020ca58ddcd7572cff7ed3b4a1a909beddc3b Mon Sep 17 00:00:00 2001 From: Testing Git Date: Tue, 12 Mar 2024 14:59:31 +0000 Subject: [PATCH 3/4] Version updated from 0.18.3 to 0.19.0 --- CHANGELOG.md | 8 ++++++-- bumpversion/__init__.py | 2 +- pyproject.toml | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 632661ab..5126c1f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,12 @@ # Changelog -## Unreleased (2024-03-12) -[Compare the full difference.](https://github.com/callowayproject/bump-my-version/compare/0.18.3...HEAD) +## 0.19.0 (2024-03-12) +[Compare the full difference.](https://github.com/callowayproject/bump-my-version/compare/0.18.3...0.19.0) +### Fixes + +- Fixing version hint generation. [ae1732b](https://github.com/callowayproject/bump-my-version/commit/ae1732b4a9b543992f83677263bb242c49c0f5c5) + ### Updates - Removes ability to call the CLI without subcommand. [e56c944](https://github.com/callowayproject/bump-my-version/commit/e56c944699151d589cec2b16a52f15cf56d151e6) diff --git a/bumpversion/__init__.py b/bumpversion/__init__.py index fd9dd918..00069b3c 100644 --- a/bumpversion/__init__.py +++ b/bumpversion/__init__.py @@ -1,3 +1,3 @@ """Top-level package for bump-my-version.""" -__version__: str = "0.18.3" +__version__: str = "0.19.0" diff --git a/pyproject.toml b/pyproject.toml index 816c50ad..d95f95a6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -213,7 +213,7 @@ order-by-type = true convention = "google" [tool.bumpversion] -current_version = "0.18.3" +current_version = "0.19.0" commit = true commit_args = "--no-verify" tag = true From c9d67b5dad3a0f93abe35cd4854ee88677f07e8c Mon Sep 17 00:00:00 2001 From: Corey Oordt Date: Sat, 16 Mar 2024 09:03:44 -0500 Subject: [PATCH 4/4] Added manual version bumping in the GitHub action --- .github/workflows/version.yaml | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/.github/workflows/version.yaml b/.github/workflows/version.yaml index def335ab..d171fdd1 100644 --- a/.github/workflows/version.yaml +++ b/.github/workflows/version.yaml @@ -3,6 +3,19 @@ on: pull_request: types: [closed] branches: [master] + workflow_dispatch: + inputs: + releaseType: + description: 'What kind of release is this?' + required: false + default: 'auto' + type: choice + options: + - 'auto' + - 'major' + - 'minor' + - 'patch' + - 'dev' jobs: version: @@ -36,6 +49,14 @@ jobs: echo "release-kind=$RELEASE_KIND" >> $GITHUB_OUTPUT echo "PACKAGE=false" >> $GITHUB_ENV + - name: Override release kind on manual + if: ${{ github.event.inputs.releaseType != 'auto' }} + id: override-release-kind + run: | + echo "::notice::Overriding release type to ${{ github.event.inputs.releaseType }} since this was a manual trigger" + echo "RELEASE_KIND=${{ github.event.inputs.releaseType }}" >> $GITHUB_ENV + echo "release-kind=${{ github.event.inputs.releaseType }}" >> $GITHUB_OUTPUT + - name: Get Pull Request Number id: pr run: | @@ -59,7 +80,7 @@ jobs: echo "PACKAGE=true" >> $GITHUB_ENV ;; dev) - echo "Intentionally not bumping version for dev release" + bump-my-version bump --allow-dirty --verbose --no-commit --no-tag "$RELEASE_KIND" ;; esac