Skip to content
This repository was archived by the owner on Apr 13, 2023. It is now read-only.

Commit c38cf01

Browse files
authored
Merge pull request #512 from staticdev/feature/add-git-diff
Add batch git diff
2 parents 9077646 + 5c21479 commit c38cf01

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Features
4040
--------
4141

4242
* Configure multiple working repositories.
43-
* Batch git_ command with subcommands `add`, `checkout`, `commit`, `pull`, `push`, `reset` and `status`.
43+
* Batch git_ command with subcommands `add`, `checkout`, `commit`, `diff`, `pull`, `push`, `reset` and `status`.
4444
* Batch create/close/reopen issues, create pull requests, merge pull requests and delete branches by name on GitHub.
4545
* Batch poetry commands such as `version patch`, `install`, `update` or `add`.
4646

src/git_portfolio/__main__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,16 @@ def commit(args: tuple[str]) -> res.ResponseFailure | res.ResponseSuccess:
125125
)
126126

127127

128+
@main.command("diff", context_settings={"ignore_unknown_options": True})
129+
@click.argument("args", nargs=-1)
130+
@gitp_config_check
131+
def diff(args: tuple[str]) -> res.ResponseFailure | res.ResponseSuccess:
132+
"""Batch `git diff` command."""
133+
return git.GitUseCase().execute(
134+
CONFIG_MANAGER.config.github_selected_repos, "diff", args
135+
)
136+
137+
128138
@main.command("pull", context_settings={"ignore_unknown_options": True})
129139
@click.argument("args", nargs=-1)
130140
@gitp_config_check

tests/test_main.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,17 @@ def test_commit_success(
263263
)
264264

265265

266+
def test_diff_success(
267+
mock_git_use_case: MockerFixture,
268+
mock_config_manager: MockerFixture,
269+
runner: CliRunner,
270+
) -> None:
271+
"""It calls diff."""
272+
runner.invoke(git_portfolio.__main__.main, ["diff"], prog_name="gitp")
273+
274+
mock_git_use_case.return_value.execute.assert_called_once_with([REPO], "diff", ())
275+
276+
266277
def test_pull_success(
267278
mock_git_use_case: MockerFixture,
268279
mock_config_manager: MockerFixture,

0 commit comments

Comments
 (0)