fix: check for git installation before cloning repository in HTTP handler
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
parent
197926a8a8
commit
1f0368f1dd
1 changed files with 7 additions and 1 deletions
|
|
@ -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
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue