Skip to content

Commit 13bf977

Browse files
committed
Improve check_repo_exists
1 parent fbef2ff commit 13bf977

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/gitingest/clone.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,19 @@
77

88
async def check_repo_exists(url: str) -> bool:
99
proc = await asyncio.create_subprocess_exec(
10-
"git",
11-
"ls-remote",
10+
"curl",
11+
"-I",
1212
url,
1313
stdout=asyncio.subprocess.PIPE,
1414
stderr=asyncio.subprocess.PIPE,
1515
)
16-
await proc.communicate()
17-
return proc.returncode == 0
16+
print("Checking if repo exists")
17+
stdout, stderr = await proc.communicate()
18+
if proc.returncode != 0:
19+
return False
20+
# Check if stdout contains "404" status code
21+
stdout_str = stdout.decode()
22+
return "HTTP/1.1 404" not in stdout_str and "HTTP/2 404" not in stdout_str
1823

1924
@async_timeout(CLONE_TIMEOUT)
2025
async def clone_repo(query: dict) -> str:

0 commit comments

Comments
 (0)