fixed: switch_to_default_branch - robust patch

https://github.com/ltdrdata/ComfyUI-Manager/issues/1392#issuecomment-2569675066
This commit is contained in:
Dr.Lt.Data
2025-01-04 09:48:56 +09:00
parent 4dee009d51
commit faf1209eba
3 changed files with 24 additions and 6 deletions

View File

@@ -127,8 +127,17 @@ def gitcheck(path, do_fetch=False):
def switch_to_default_branch(repo):
default_branch = repo.git.symbolic_ref('refs/remotes/origin/HEAD').replace('refs/remotes/origin/', '')
repo.git.checkout(default_branch)
try:
default_branch = repo.git.symbolic_ref('refs/remotes/origin/HEAD').replace('refs/remotes/origin/', '')
repo.git.checkout(default_branch)
except:
try:
repo.git.checkout(repo.heads.master)
except:
try:
repo.git.checkout(repo.heads.main)
except:
print("[ComfyUI Manager] Failed to switch to the default branch (master or main)")
def gitpull(path):