Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowing picking of specific branch in --url/--manager-url options for comfy install command #147

Merged
merged 5 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions comfy_cli/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,19 @@ def entry(
@app.command(help="Download and install ComfyUI and ComfyUI-Manager")
@tracking.track_command()
def install(
url: Annotated[str, typer.Option(show_default=False)] = constants.COMFY_GITHUB_URL,
url: Annotated[
str,
typer.Option(
show_default=False,
help="url or local path pointing to the ComfyUI core git repo to be installed. A specific branch can optionally be specified using a setuptools-like syntax, eg https://foo.git@bar",
),
] = constants.COMFY_GITHUB_URL,
manager_url: Annotated[
str, typer.Option(show_default=False)
str,
typer.Option(
show_default=False,
help="url or local path pointing to the ComfyUI-Manager git repo to be installed. A specific branch can optionally be specified using a setuptools-like syntax, eg https://foo.git@bar",
),
] = constants.COMFY_MANAGER_GITHUB_URL,
restore: Annotated[
bool,
Expand Down
24 changes: 19 additions & 5 deletions comfy_cli/command/install.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from rich import print
import os
import platform
import subprocess
import sys

import typer
from rich import print
from typing import Optional

from comfy_cli import constants, ui, utils
from comfy_cli.command.custom_nodes.command import update_node_id_cache
Expand Down Expand Up @@ -163,7 +163,7 @@ def execute(
comfy_path: str,
restore: bool,
skip_manager: bool,
commit=None,
commit: Optional[str] = None,
gpu: constants.GPU_OPTION = None,
cuda_version: constants.CUDAVersion = constants.CUDAVersion.v12_1,
plat: constants.OS = None,
Expand All @@ -189,7 +189,14 @@ def execute(
os.makedirs(parent_path, exist_ok=True)

if not os.path.exists(repo_dir):
subprocess.run(["git", "clone", url, repo_dir], check=True)
if "@" in url:
# clone specific branch
url, branch = url.rsplit("@", 1)

subprocess.run(["git", "clone", "-b", branch, url, repo_dir], check=True)
else:
subprocess.run(["git", "clone", url, repo_dir], check=True)

elif not check_comfy_repo(repo_dir)[0]:
print(
f"[bold red]'{repo_dir}' already exists. But it is an invalid ComfyUI repository. Remove it and retry.[/bold red]"
Expand Down Expand Up @@ -226,7 +233,14 @@ def execute(
else:
print("\nInstalling ComfyUI-Manager..")

subprocess.run(["git", "clone", manager_url, manager_repo_dir], check=True)
if "@" in manager_url:
# clone specific branch
manager_url, manager_branch = manager_url.rsplit("@", 1)

subprocess.run(["git", "clone", "-b", manager_branch, manager_url, manager_repo_dir], check=True)
else:
subprocess.run(["git", "clone", manager_url, manager_repo_dir], check=True)

install_manager_dependencies(repo_dir)

update_node_id_cache()
Expand Down
Loading