Skip to content
Open
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
15 changes: 10 additions & 5 deletions memov/core/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ def subprocess_call(
"check": True,
"stdout": subprocess.PIPE,
"stderr": subprocess.PIPE,
"encoding": "utf-8",
"text": text,
}

if text:
kwargs["encoding"] = "utf-8"
if input is not None:
kwargs["input"] = input
else:
Expand Down Expand Up @@ -291,9 +292,12 @@ def git_show(bare_repo: str, commit_id: str) -> None:
command = ["git", f"--git-dir={bare_repo}", "show", commit_id]
success, output = subprocess_call(command=command)

sys.stdout.write(output.stdout)
if output.stderr:
sys.stderr.write(output.stderr)
if success and output:
sys.stdout.write(output.stdout)
if output.stderr:
sys.stderr.write(output.stderr)
else:
LOGGER.error(f"Failed to show commit {commit_id} in repository at {bare_repo}")

@staticmethod
def get_commit_history(bare_repo: str, tip: str) -> list[str]:
Expand All @@ -312,8 +316,9 @@ def get_commit_history(bare_repo: str, tip: str) -> list[str]:
if success:
return output.stdout.strip().splitlines()
else:
err_msg = output.stderr if output else "Unknown error"
LOGGER.error(
f"Failed to get commit history for {tip} in repository at {bare_repo}: {output.stderr}"
f"Failed to get commit history for {tip} in repository at {bare_repo}: {err_msg}"
)
return []

Expand Down