Skip to content

Commit 3bb13a1

Browse files
committed
add error message when git missing
1 parent dceff33 commit 3bb13a1

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/gitingest/repository_clone.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,24 @@ async def _run_git_command(*args: str) -> tuple[bytes, bytes]:
193193
Raises
194194
------
195195
RuntimeError
196-
If the Git command exits with a non-zero status.
196+
If Git is not installed or if the Git command exits with a non-zero status.
197197
"""
198+
# Check if Git is installed
199+
try:
200+
version_proc = await asyncio.create_subprocess_exec(
201+
"git",
202+
"--version",
203+
stdout=asyncio.subprocess.PIPE,
204+
stderr=asyncio.subprocess.PIPE,
205+
)
206+
_, stderr = await version_proc.communicate()
207+
if version_proc.returncode != 0:
208+
error_message = stderr.decode().strip() if stderr else "Git command not found"
209+
raise RuntimeError(f"Git is not installed or not accessible: {error_message}")
210+
except FileNotFoundError as exc:
211+
raise RuntimeError("Git is not installed. Please install Git before proceeding.") from exc
212+
213+
# Execute the requested Git command
198214
proc = await asyncio.create_subprocess_exec(
199215
*args,
200216
stdout=asyncio.subprocess.PIPE,

0 commit comments

Comments
 (0)