Update app/api/v1/repositories.py
Browse files
app/api/v1/repositories.py
CHANGED
|
@@ -161,6 +161,12 @@ async def add_repository(
|
|
| 161 |
if not repository.github_url.startswith(('https://github.com/', 'git@github.com:')):
|
| 162 |
raise HTTPException(status_code=400, detail="Invalid GitHub URL format")
|
| 163 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
# Check for duplicates for this user
|
| 165 |
existing = db.query(Repository).filter(
|
| 166 |
Repository.github_url == repository.github_url,
|
|
|
|
| 161 |
if not repository.github_url.startswith(('https://github.com/', 'git@github.com:')):
|
| 162 |
raise HTTPException(status_code=400, detail="Invalid GitHub URL format")
|
| 163 |
|
| 164 |
+
# Fast synchronous pre-validation
|
| 165 |
+
github_service = GitHubService()
|
| 166 |
+
is_valid, error_msg = await github_service.verify_repository(repository.github_url)
|
| 167 |
+
if not is_valid:
|
| 168 |
+
raise HTTPException(status_code=400, detail=error_msg)
|
| 169 |
+
|
| 170 |
# Check for duplicates for this user
|
| 171 |
existing = db.query(Repository).filter(
|
| 172 |
Repository.github_url == repository.github_url,
|