diff --git a/README.rst b/README.rst index a71f220f..af8e6536 100644 --- a/README.rst +++ b/README.rst @@ -40,7 +40,7 @@ Features -------- * Configure multiple working repositories. -* Batch git_ command with subcommands `add`, `checkout`, `commit`, `pull`, `push`, `reset` and `status`. +* Batch git_ command with subcommands `add`, `checkout`, `commit`, `diff`, `pull`, `push`, `reset` and `status`. * Batch create/close/reopen issues, create pull requests, merge pull requests and delete branches by name on GitHub. * Batch poetry commands such as `version patch`, `install`, `update` or `add`. diff --git a/src/git_portfolio/__main__.py b/src/git_portfolio/__main__.py index f6009e61..1ea36c6a 100644 --- a/src/git_portfolio/__main__.py +++ b/src/git_portfolio/__main__.py @@ -125,6 +125,16 @@ def commit(args: tuple[str]) -> res.ResponseFailure | res.ResponseSuccess: ) +@main.command("diff", context_settings={"ignore_unknown_options": True}) +@click.argument("args", nargs=-1) +@gitp_config_check +def diff(args: tuple[str]) -> res.ResponseFailure | res.ResponseSuccess: + """Batch `git diff` command.""" + return git.GitUseCase().execute( + CONFIG_MANAGER.config.github_selected_repos, "diff", args + ) + + @main.command("pull", context_settings={"ignore_unknown_options": True}) @click.argument("args", nargs=-1) @gitp_config_check diff --git a/tests/test_main.py b/tests/test_main.py index a3723560..089e0007 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -263,6 +263,17 @@ def test_commit_success( ) +def test_diff_success( + mock_git_use_case: MockerFixture, + mock_config_manager: MockerFixture, + runner: CliRunner, +) -> None: + """It calls diff.""" + runner.invoke(git_portfolio.__main__.main, ["diff"], prog_name="gitp") + + mock_git_use_case.return_value.execute.assert_called_once_with([REPO], "diff", ()) + + def test_pull_success( mock_git_use_case: MockerFixture, mock_config_manager: MockerFixture,