From faf1209ebadc472641dd49455636534295000d70 Mon Sep 17 00:00:00 2001 From: "Dr.Lt.Data" Date: Sat, 4 Jan 2025 09:48:56 +0900 Subject: [PATCH] fixed: switch_to_default_branch - robust patch https://github.com/ltdrdata/ComfyUI-Manager/issues/1392#issuecomment-2569675066 --- git_helper.py | 13 +++++++++++-- glob/manager_core.py | 15 ++++++++++++--- pyproject.toml | 2 +- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/git_helper.py b/git_helper.py index 6c9c2a9f..9cf21104 100644 --- a/git_helper.py +++ b/git_helper.py @@ -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): diff --git a/glob/manager_core.py b/glob/manager_core.py index c39b11a7..8bc19402 100644 --- a/glob/manager_core.py +++ b/glob/manager_core.py @@ -36,7 +36,7 @@ import manager_downloader from node_package import InstalledNodePackage -version_code = [3, 3, 8] +version_code = [3, 3, 9] version_str = f"V{version_code[0]}.{version_code[1]}" + (f'.{version_code[2]}' if len(version_code) > 2 else '') @@ -1510,8 +1510,17 @@ def get_config(): 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 try_install_script(url, repo_path, install_cmd, instant_execution=False): diff --git a/pyproject.toml b/pyproject.toml index 8f6d0ba5..b27f64b9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "comfyui-manager" description = "ComfyUI-Manager provides features to install and manage custom nodes for ComfyUI, as well as various functionalities to assist with ComfyUI." -version = "3.3.8" +version = "3.3.9" license = { file = "LICENSE.txt" } dependencies = ["GitPython", "PyGithub", "matrix-client==0.4.0", "transformers", "huggingface-hub>0.20", "typer", "rich", "typing-extensions"]