Skip to content

Commit 4f62daa

Browse files
committed
Improve error message for private repo
1 parent 1aeed52 commit 4f62daa

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/utils/clone.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,31 @@
11
import asyncio
2+
from typing import Tuple
23

34
from .decorators import async_timeout
45
from config import CLONE_TIMEOUT
56

7+
async def check_repo_exists(url: str) -> Tuple[bool, str]:
8+
"""
9+
Check if a repository exists and is accessible.
10+
Returns a tuple of (exists: bool, error_message: str)
11+
"""
12+
proc = await asyncio.create_subprocess_exec(
13+
"git",
14+
"ls-remote",
15+
url,
16+
stdout=asyncio.subprocess.PIPE,
17+
stderr=asyncio.subprocess.PIPE,
18+
)
19+
_, stderr = await proc.communicate()
20+
if proc.returncode != 0:
21+
return False
22+
return True
623

724
@async_timeout(CLONE_TIMEOUT)
825
async def clone_repo(query: dict) -> str:
9-
26+
if not await check_repo_exists(query['url']):
27+
raise ValueError("Repository not found, make sure it is public")
28+
1029
if query['commit']:
1130
proc = await asyncio.create_subprocess_exec(
1231
"git",

0 commit comments

Comments
 (0)