diff --git a/git_helper.py b/git_helper.py index e79b43a6..4e184a3b 100644 --- a/git_helper.py +++ b/git_helper.py @@ -2,6 +2,7 @@ import subprocess import sys import os import traceback +import time import git import json @@ -219,7 +220,14 @@ def gitpull(path): repo.close() return - remote.pull() + try: + repo.git.pull('--ff-only') + except git.GitCommandError: + backup_name = f'backup_{time.strftime("%Y%m%d_%H%M%S")}' + repo.create_head(backup_name) + print(f"[ComfyUI-Manager] Cannot fast-forward. Backup created: {backup_name}") + repo.git.reset('--hard', f'{remote_name}/{branch_name}') + print(f"[ComfyUI-Manager] Reset to {remote_name}/{branch_name}") repo.git.submodule('update', '--init', '--recursive') new_commit_hash = repo.head.commit.hexsha diff --git a/glob/manager_core.py b/glob/manager_core.py index 32b90523..c9d38138 100644 --- a/glob/manager_core.py +++ b/glob/manager_core.py @@ -44,7 +44,7 @@ import manager_migration from node_package import InstalledNodePackage -version_code = [3, 38, 1] +version_code = [3, 38, 2] version_str = f"V{version_code[0]}.{version_code[1]}" + (f'.{version_code[2]}' if len(version_code) > 2 else '') @@ -2253,9 +2253,17 @@ def git_pull(path): current_branch = repo.active_branch remote_name = current_branch.tracking_branch().remote_name - remote = repo.remote(name=remote_name) - remote.pull() + try: + repo.git.pull('--ff-only') + except git.GitCommandError: + branch_name = current_branch.name + backup_name = f'backup_{time.strftime("%Y%m%d_%H%M%S")}' + repo.create_head(backup_name) + logging.info(f"[ComfyUI-Manager] Cannot fast-forward. Backup created: {backup_name}") + repo.git.reset('--hard', f'{remote_name}/{branch_name}') + logging.info(f"[ComfyUI-Manager] Reset to {remote_name}/{branch_name}") + repo.git.submodule('update', '--init', '--recursive') repo.close() diff --git a/pyproject.toml b/pyproject.toml index 4ffbec0f..1f795895 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.38.1" +version = "3.38.2" license = { file = "LICENSE.txt" } dependencies = ["GitPython", "PyGithub", "matrix-nio", "transformers", "huggingface-hub>0.20", "typer", "rich", "typing-extensions", "toml", "uv", "chardet"]