fix: check for git installation before cloning repository in HTTP handler

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
Jakub Dorfman 2026-04-29 18:38:29 +02:00
parent eac94061d0
commit 4ec759296b

View file

@ -602,6 +602,12 @@ class Handler(BaseHTTPRequestHandler):
return
# Clone the repository
git_bin = shutil.which("git")
if not git_bin:
run_panelctl(["remove", name])
self._json(400, {"ok": False, "error": "git is not installed or not in PATH"})
return
target_dir = os.path.join(app["APP_STACK_DIR"], "repo")
if os.path.exists(target_dir):
shutil.rmtree(target_dir)
@ -614,7 +620,7 @@ class Handler(BaseHTTPRequestHandler):
auth_url += ".git"
clone_result = subprocess.run(
["git", "clone", "--branch", branch, auth_url, target_dir],
[git_bin, "clone", "--branch", branch, auth_url, target_dir],
capture_output=True, text=True
)