Skip to content

Commit 02e642a

Browse files
committed
feat: support --commit in comfy install
#11
1 parent 0473c97 commit 02e642a

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

comfy_cli/cmdline.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,16 @@ def install(
7979
] = False,
8080
skip_manager: Annotated[
8181
bool,
82-
typer.Option(
83-
help="Skip installing the manager component")
82+
typer.Option(help="Skip installing the manager component")
8483
] = False,
8584
amd: Annotated[
8685
bool,
87-
typer.Option(
88-
help="Install for AMD gpu")
86+
typer.Option(help="Install for AMD gpu")
8987
] = False,
88+
commit: Annotated[
89+
str,
90+
typer.Option(help="Specify commit hash for ComfyUI")
91+
] = None
9092
):
9193
checker = EnvChecker()
9294

@@ -119,7 +121,7 @@ def install(
119121
if amd:
120122
torch_mode = 'amd'
121123

122-
install_inner.execute(url, manager_url, workspace_path, restore, skip_manager, torch_mode)
124+
install_inner.execute(url, manager_url, workspace_path, restore, skip_manager, torch_mode, commit=commit)
123125
workspace_manager.set_recent_workspace(workspace_path)
124126

125127

comfy_cli/command/install.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ def install_manager_dependencies(repo_dir):
2424
subprocess.run([sys.executable, '-m', "pip", "install", "-r", "requirements.txt"])
2525

2626

27-
def execute(url: str, manager_url: str, comfy_workspace: str, restore: bool, skip_manager: bool, torch_mode=None, *args,
28-
**kwargs):
27+
def execute(url: str, manager_url: str, comfy_workspace: str, restore: bool, skip_manager: bool, torch_mode=None, commit=None,
28+
*args, **kwargs):
2929
print(f"Installing from {url}")
3030

3131
# install ComfyUI
@@ -34,7 +34,11 @@ def execute(url: str, manager_url: str, comfy_workspace: str, restore: bool, ski
3434
repo_dir = os.path.abspath(repo_dir)
3535

3636
if os.path.exists(os.path.join(repo_dir, '.git')):
37-
if restore:
37+
if restore or commit is not None:
38+
if commit is not None:
39+
os.chdir(repo_dir)
40+
subprocess.run(["git", "checkout", commit])
41+
3842
install_comfyui_dependencies(repo_dir, torch_mode)
3943
else:
4044
print(
@@ -47,6 +51,11 @@ def execute(url: str, manager_url: str, comfy_workspace: str, restore: bool, ski
4751
repo_dir = os.path.abspath(repo_dir)
4852
subprocess.run(["git", "clone", url, repo_dir])
4953

54+
# checkout specified commit
55+
if commit is not None:
56+
os.chdir(repo_dir)
57+
subprocess.run(["git", "checkout", commit])
58+
5059
install_comfyui_dependencies(repo_dir, torch_mode)
5160

5261
print("")

0 commit comments

Comments
 (0)