fix: check for git installation before cloning repository in HTTP handler
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
parent
eac94061d0
commit
4ec759296b
1 changed files with 7 additions and 1 deletions
|
|
@ -602,6 +602,12 @@ class Handler(BaseHTTPRequestHandler):
|
||||||
return
|
return
|
||||||
|
|
||||||
# Clone the repository
|
# 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")
|
target_dir = os.path.join(app["APP_STACK_DIR"], "repo")
|
||||||
if os.path.exists(target_dir):
|
if os.path.exists(target_dir):
|
||||||
shutil.rmtree(target_dir)
|
shutil.rmtree(target_dir)
|
||||||
|
|
@ -614,7 +620,7 @@ class Handler(BaseHTTPRequestHandler):
|
||||||
auth_url += ".git"
|
auth_url += ".git"
|
||||||
|
|
||||||
clone_result = subprocess.run(
|
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
|
capture_output=True, text=True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue