Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions tagbot/action/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,16 @@ def command(self, *argv: str, repo: Optional[str] = "") -> str:
proc = subprocess.run(args, text=True, capture_output=True)
out = proc.stdout.strip()
if proc.returncode:
error_msg = f"Git command '{self._sanitize_command(cmd)}' failed"
if out:
logger.info(self._sanitize_command(out))
stdout = self._sanitize_command(out)
logger.error(f"stdout: {stdout}")
error_msg += f"\nstdout: {stdout}"
if proc.stderr:
logger.info(self._sanitize_command(proc.stderr.strip()))
raise Abort(f"Git command '{self._sanitize_command(cmd)}' failed")
stderr = self._sanitize_command(proc.stderr.strip())
logger.error(f"stderr: {stderr}")
error_msg += f"\nstderr: {stderr}"
raise Abort(error_msg)
return out

def check(self, *argv: str, repo: Optional[str] = "") -> bool:
Expand Down
3 changes: 2 additions & 1 deletion test/action/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ def test_command(run):
]
run.assert_has_calls(calls)
run.return_value.configure_mock(stderr="err\n", returncode=1)
with pytest.raises(Abort):
with pytest.raises(Abort) as exc_info:
g.command("d")
assert "stderr: err" in str(exc_info.value)


def test_check():
Expand Down