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

Commit abae37b

Browse files
author
Thiago C. D'Ávila
authored
Merge pull request #115 from staticdev/add-git-reset
Add git reset
2 parents e5a343f + f7116b0 commit abae37b

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-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 add`, `git checkout`, `git commit`, `git pull`, `git push` and `git status`.
43+
* Batch `git` command with subcommands `add`, `checkout`, `commit`, `pull`, `push`, `reset` and `status`.
4444
* Batch creation of issues, creation of pull requests, merge of pull requests and deletion branches by name on GitHub.
4545

4646

src/git_portfolio/__main__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,16 @@ def push(args: Tuple[str]) -> Union[res.ResponseFailure, res.ResponseSuccess]:
104104
)
105105

106106

107+
@main.command("reset", context_settings={"ignore_unknown_options": True})
108+
@click.argument("args", nargs=-1)
109+
@git_command
110+
def reset(args: Tuple[str]) -> Union[res.ResponseFailure, res.ResponseSuccess]:
111+
"""Batch `git reset` command."""
112+
return guc.GitUseCase().execute(
113+
CONFIG_MANAGER.config.github_selected_repos, "reset", args
114+
)
115+
116+
107117
@main.command("status")
108118
@click.argument("args", nargs=-1)
109119
@git_command

tests/test_main.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,36 @@ def test_push_with_extra_arguments(
209209
)
210210

211211

212+
def test_reset_success(
213+
mock_git_use_case: MockerFixture,
214+
mock_config_manager: MockerFixture,
215+
runner: CliRunner,
216+
) -> None:
217+
"""It calls reset with HEAD^."""
218+
mock_config_manager.config.github_selected_repos = ["staticdev/omg"]
219+
runner.invoke(git_portfolio.__main__.main, ["reset", "HEAD^"], prog_name="gitp")
220+
221+
mock_git_use_case.return_value.execute.assert_called_once_with(
222+
["staticdev/omg"], "reset", ("HEAD^",)
223+
)
224+
225+
226+
def test_reset_success_with_hard(
227+
mock_git_use_case: MockerFixture,
228+
mock_config_manager: MockerFixture,
229+
runner: CliRunner,
230+
) -> None:
231+
"""It calls reset with --hard HEAD^."""
232+
mock_config_manager.config.github_selected_repos = ["staticdev/omg"]
233+
runner.invoke(
234+
git_portfolio.__main__.main, ["reset", "--hard", "HEAD^"], prog_name="gitp"
235+
)
236+
237+
mock_git_use_case.return_value.execute.assert_called_once_with(
238+
["staticdev/omg"], "reset", ("--hard", "HEAD^")
239+
)
240+
241+
212242
def test_status_success(
213243
mock_git_use_case: MockerFixture,
214244
mock_config_manager: MockerFixture,

0 commit comments

Comments
 (0)