Spaces:
Paused
Paused
Fix InvalidGitRepositoryError when git repo not found - Add try-except to handle cases where Repo() cannot find valid git repository, fallback to cloning default branch
Browse files- pyUltroid/startup/loader.py +13 -4
pyUltroid/startup/loader.py
CHANGED
|
@@ -86,10 +86,19 @@ def load_other_plugins(addons=None, pmbot=None, manager=None, vcbot=None):
|
|
| 86 |
print(f"[Permission Fix] Could not change permissions for 'addons': {e}")
|
| 87 |
rmtree("addons")
|
| 88 |
if not os.path.exists("addons"):
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
else:
|
| 94 |
subprocess.run("cd addons && git pull -q && cd ..", shell=True)
|
| 95 |
|
|
|
|
| 86 |
print(f"[Permission Fix] Could not change permissions for 'addons': {e}")
|
| 87 |
rmtree("addons")
|
| 88 |
if not os.path.exists("addons"):
|
| 89 |
+
# Try to get the active branch, fallback to default if repo not found
|
| 90 |
+
try:
|
| 91 |
+
branch = Repo().active_branch
|
| 92 |
+
subprocess.run(
|
| 93 |
+
f"git clone -q -b {branch} https://github.com/TeamUltroid/UltroidAddons.git addons",
|
| 94 |
+
shell=True,
|
| 95 |
+
)
|
| 96 |
+
except Exception:
|
| 97 |
+
# If git repo not found (InvalidGitRepositoryError) or branch can't be determined, clone default branch
|
| 98 |
+
subprocess.run(
|
| 99 |
+
"git clone -q https://github.com/TeamUltroid/UltroidAddons.git addons",
|
| 100 |
+
shell=True,
|
| 101 |
+
)
|
| 102 |
else:
|
| 103 |
subprocess.run("cd addons && git pull -q && cd ..", shell=True)
|
| 104 |
|