Browse Source

improve: print log for updated extension

pull/113/head
dr.lt.data 1 year ago
parent
commit
7688c08000
  1. 22
      __init__.py
  2. 8
      git_helper.py

22
__init__.py

@ -55,7 +55,7 @@ sys.path.append('../..')
from torchvision.datasets.utils import download_url from torchvision.datasets.utils import download_url
# ensure .js # ensure .js
print("### Loading: ComfyUI-Manager (V0.28.1)") print("### Loading: ComfyUI-Manager (V0.28.2)")
comfy_ui_required_revision = 1240 comfy_ui_required_revision = 1240
comfy_ui_revision = "Unknown" comfy_ui_revision = "Unknown"
@ -250,6 +250,10 @@ def __win_check_git_update(path, do_fetch=False, do_update=False):
if do_update: if do_update:
if "CUSTOM NODE PULL: True" in output: if "CUSTOM NODE PULL: True" in output:
process.wait()
print(f"\rUpdated: '{path}'")
return True
elif "CUSTOM NODE PULL: None" in output:
process.wait() process.wait()
return True return True
else: else:
@ -294,17 +298,25 @@ def git_repo_has_updates(path, do_fetch=False, do_update=False):
remote_name = 'origin' remote_name = 'origin'
remote = repo.remote(name=remote_name) remote = repo.remote(name=remote_name)
if do_fetch: # Get the current commit hash
commit_hash = repo.head.commit.hexsha
if do_fetch or do_update:
remote.fetch() remote.fetch()
elif do_update:
if do_update:
try: try:
remote.pull(rebase=True) remote.pull(rebase=True)
repo.git.submodule('update', '--init', '--recursive') repo.git.submodule('update', '--init', '--recursive')
new_commit_hash = repo.head.commit.hexsha
if commit_hash != new_commit_hash:
print(f"\rUpdated: '{path}'")
except Exception as e: except Exception as e:
print(f"Updating failed: '{path}'\n{e}") print(f"Updating failed: '{path}'\n{e}")
# Get the current commit hash and the commit hash of the remote branch # Get commit hash of the remote branch
commit_hash = repo.head.commit.hexsha
remote_commit_hash = repo.refs[f'{remote_name}/{branch_name}'].object.hexsha remote_commit_hash = repo.refs[f'{remote_name}/{branch_name}'].object.hexsha
# Compare the commit hashes to determine if the local repository is behind the remote repository # Compare the commit hashes to determine if the local repository is behind the remote repository

8
git_helper.py

@ -50,11 +50,17 @@ def gitpull(path):
if repo.is_dirty(): if repo.is_dirty():
repo.git.stash() repo.git.stash()
commit_hash = repo.head.commit.hexsha
try: try:
origin = repo.remote(name='origin') origin = repo.remote(name='origin')
origin.pull(rebase=True) origin.pull(rebase=True)
repo.git.submodule('update', '--init', '--recursive') repo.git.submodule('update', '--init', '--recursive')
print("CUSTOM NODE PULL: True") new_commit_hash = repo.head.commit.hexsha
if commit_hash != new_commit_hash:
print("CUSTOM NODE PULL: True")
else:
print("CUSTOM NODE PULL: None")
except Exception as e: except Exception as e:
print(e) print(e)
print("CUSTOM NODE PULL: False") print("CUSTOM NODE PULL: False")

Loading…
Cancel
Save