GitPasha MCP Server - Ready for deployment
هذا الالتزام موجود في:
43
api/repos/update.py
Normal file
43
api/repos/update.py
Normal file
@@ -0,0 +1,43 @@
|
||||
import os
|
||||
from typing import Dict, Any, Optional
|
||||
from helpers import get_headers, build_client
|
||||
|
||||
BASE_URL = os.getenv(
|
||||
"GITPASHA_BASE_URL",
|
||||
"https://app.gitpasha.com/api/v1"
|
||||
).rstrip("/")
|
||||
|
||||
|
||||
def api_update_repo(
|
||||
repo: str,
|
||||
name: Optional[str] = None,
|
||||
description: Optional[str] = None,
|
||||
private: Optional[bool] = None
|
||||
) -> Dict[str, Any]:
|
||||
username = os.getenv("GITPASHA__USERNAME", "")
|
||||
|
||||
if "/" not in repo:
|
||||
if not username:
|
||||
raise ValueError("GITPASHA__USERNAME not set in .env")
|
||||
repo = f"{username}/{repo}"
|
||||
|
||||
payload: Dict[str, Any] = {}
|
||||
if name is not None:
|
||||
payload["name"] = name
|
||||
if description is not None:
|
||||
payload["description"] = description
|
||||
if private is not None:
|
||||
payload["private"] = bool(private)
|
||||
if not payload:
|
||||
raise ValueError("No fields to update")
|
||||
|
||||
with build_client() as client:
|
||||
url = f"{BASE_URL}/repos/{repo}"
|
||||
res = client.patch(url, headers=get_headers(), json=payload)
|
||||
if res.status_code == 405:
|
||||
res = client.put(url, headers=get_headers(), json=payload)
|
||||
res.raise_for_status()
|
||||
try:
|
||||
return res.json()
|
||||
except Exception:
|
||||
return {"status": "ok"}
|
||||
المرجع في مشكلة جديدة
حظر مستخدم