aboutsummaryrefslogtreecommitdiff
path: root/modules/launch_utils.py
diff options
context:
space:
mode:
authorJabasukuriputo Wang <wfjsw@users.noreply.github.com>2023-08-10 09:18:10 -0500
committerGitHub <noreply@github.com>2023-08-10 09:18:10 -0500
commit5a705c246880c26ec4fc940dae0da5ecdd2bff50 (patch)
tree8d8f08efc32faf19122d1174c65c7b2c637961ac /modules/launch_utils.py
parent959404e0e29531d24f2e02088bf0399f4b9db15b (diff)
rm dir on failed clone, disable autofix for fetch
Diffstat (limited to 'modules/launch_utils.py')
-rw-r--r--modules/launch_utils.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/modules/launch_utils.py b/modules/launch_utils.py
index 90c00dd2..953f968b 100644
--- a/modules/launch_utils.py
+++ b/modules/launch_utils.py
@@ -3,6 +3,7 @@ import logging
import re
import subprocess
import os
+import shutil
import sys
import importlib.util
import platform
@@ -152,10 +153,8 @@ def run_git(dir, name, command, desc=None, errdesc=None, custom_env=None, live:
try:
return run(f'"{git}" -C "{dir}" {command}', desc=desc, errdesc=errdesc, custom_env=custom_env, live=live)
except RuntimeError:
- pass
-
- if not autofix:
- return None
+ if not autofix:
+ raise
print(f"{errdesc}, attempting autofix...")
git_fix_workspace(dir, name)
@@ -174,13 +173,17 @@ def git_clone(url, dir, name, commithash=None):
if current_hash == commithash:
return
- run_git('fetch', f"Fetching updates for {name}...", f"Couldn't fetch {name}")
+ run_git('fetch', f"Fetching updates for {name}...", f"Couldn't fetch {name}", autofix=False)
run_git('checkout', f"Checking out commit for {name} with hash: {commithash}...", f"Couldn't checkout commit {commithash} for {name}", live=True)
return
- run(f'"{git}" clone "{url}" "{dir}"', f"Cloning {name} into {dir}...", f"Couldn't clone {name}", live=True)
+ try:
+ run(f'"{git}" clone "{url}" "{dir}"', f"Cloning {name} into {dir}...", f"Couldn't clone {name}", live=True)
+ except RuntimeError:
+ shutil.rmtree(dir, ignore_errors=True)
+ raise
if commithash is not None:
run(f'"{git}" -C "{dir}" checkout {commithash}', None, "Couldn't checkout {name}'s hash: {commithash}")