haiyizxx commited on
Commit
0f2eb35
·
1 Parent(s): 224f96a

fix: set GIT_TERMINAL_PROMPT=0 to prevent clone hanging

Browse files
Files changed (1) hide show
  1. app.py +3 -29
app.py CHANGED
@@ -27,6 +27,8 @@ def _clone_repo(workdir: Path) -> Path:
27
  subprocess.run(
28
  ["git", "clone", "--depth", "1", "-b", REPO_REF, repo_url, str(repo_dir)],
29
  check=True,
 
 
30
  )
31
  return repo_dir
32
 
@@ -86,34 +88,6 @@ async def cvat_webhook(request: Request):
86
  return {"status": "accepted", "task_id": task_id}
87
 
88
 
89
- @app.get("/test-clone")
90
- async def test_clone():
91
- """Debug: test git clone with PAT."""
92
- import tempfile
93
- repo_url = REPO_URL
94
- if GITHUB_PAT and "github.com" in repo_url:
95
- repo_url = repo_url.replace("https://", f"https://{GITHUB_PAT}@")
96
- with tempfile.TemporaryDirectory() as td:
97
- result = subprocess.run(
98
- ["git", "clone", "--depth", "1", "-b", REPO_REF, repo_url, f"{td}/repo"],
99
- capture_output=True, text=True, timeout=30,
100
- env={**os.environ, "GIT_TERMINAL_PROMPT": "0"},
101
- )
102
- return {
103
- "returncode": result.returncode,
104
- "stdout": result.stdout[:500],
105
- "stderr": result.stderr[:500],
106
- }
107
-
108
-
109
  @app.get("/health")
110
  async def health():
111
- return {
112
- "status": "ok",
113
- "dataset": DATASET,
114
- "has_github_pat": bool(GITHUB_PAT),
115
- "github_pat_prefix": GITHUB_PAT[:15] + "..." if GITHUB_PAT else "",
116
- "has_cvat_token": bool(CVAT_TOKEN),
117
- "repo_ref": REPO_REF,
118
- "repo_url": REPO_URL,
119
- }
 
27
  subprocess.run(
28
  ["git", "clone", "--depth", "1", "-b", REPO_REF, repo_url, str(repo_dir)],
29
  check=True,
30
+ timeout=120,
31
+ env={**os.environ, "GIT_TERMINAL_PROMPT": "0"},
32
  )
33
  return repo_dir
34
 
 
88
  return {"status": "accepted", "task_id": task_id}
89
 
90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  @app.get("/health")
92
  async def health():
93
+ return {"status": "ok", "dataset": DATASET}