Fix get version git fallback

This commit is contained in:
huchenlei 2024-08-30 10:35:09 -04:00
parent 21122f9965
commit d833512213

View File

@ -44,17 +44,17 @@ async def send_socket_catch_exception(function, message):
def get_comfyui_version(): def get_comfyui_version():
comfyui_version = "unknown" comfyui_version = "unknown"
repo_path = os.path.dirname(os.path.realpath(__file__))
try: try:
import pygit2 import pygit2
repo_path = os.path.dirname(os.path.realpath(__file__))
repo = pygit2.Repository(repo_path) repo = pygit2.Repository(repo_path)
comfyui_version = repo.describe(describe_strategy=pygit2.GIT_DESCRIBE_TAGS) comfyui_version = repo.describe(describe_strategy=pygit2.GIT_DESCRIBE_TAGS)
except Exception: except Exception:
try: try:
import subprocess import subprocess
comfyui_version = subprocess.check_output(["git", "describe", "--tags"], cwd=repo_path) comfyui_version = subprocess.check_output(["git", "describe", "--tags"], cwd=repo_path)
except Exception: except Exception as e:
pass logging.warning(f"Failed to get ComfyUI version: {e}")
return comfyui_version.strip() return comfyui_version.strip()
@web.middleware @web.middleware