Skip to content

Commit 0abb3b9

Browse files
authored
fix: apply --pr validation and passthrough for --cpu install path (#370)
1 parent e159777 commit 0abb3b9

3 files changed

Lines changed: 48 additions & 5 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ Comfy provides commands that allow you to easily run the installed ComfyUI.
121121
`comfy install --pr "https://github.com/comfyanonymous/ComfyUI/pull/1234"`
122122

123123
- If you want to run ComfyUI with a specific pull request, you can use the `--pr` option. This will automatically install the specified pull request and run ComfyUI with it.
124-
- Important: When using --pr, any --version and --commit parameters are ignored. The PR branch will be checked out regardless of version settings.
124+
- Important: The --pr option cannot be combined with --version or --commit and will be rejected if used together.
125125

126126
- To test a frontend pull request:
127127

comfy_cli/cmdline.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,11 @@ def install(
269269
rprint("[bold red]Python version 3.9 or higher is required to run ComfyUI.[/bold red]")
270270
rprint(f"You are currently using Python version {env_checker.format_python_version(checker.python_version)}.")
271271
platform = utils.get_os()
272+
273+
if pr and (version not in {None, "nightly"} or commit):
274+
rprint("--pr cannot be used with --version or --commit")
275+
raise typer.Exit(code=1)
276+
272277
if cpu:
273278
rprint("[bold yellow]Installing for CPU[/bold yellow]")
274279
install_inner.execute(
@@ -286,6 +291,7 @@ def install(
286291
skip_requirement=skip_requirement,
287292
fast_deps=fast_deps,
288293
manager_commit=manager_commit,
294+
pr=pr,
289295
)
290296
rprint(f"ComfyUI is installed at: {comfy_path}")
291297
return None
@@ -325,10 +331,6 @@ def install(
325331
)
326332
raise typer.Exit(code=1)
327333

328-
if pr and (version not in {None, "nightly"} or commit):
329-
rprint("--pr cannot be used with --version or --commit")
330-
raise typer.Exit(code=1)
331-
332334
install_inner.execute(
333335
url,
334336
manager_url,

tests/comfy_cli/command/github/test_pr.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,47 @@ def test_commit_without_pr_does_not_conflict(self, mock_track, mock_ws, mock_che
312312
assert "--pr cannot be used" not in result.stdout
313313
assert mock_execute.called
314314

315+
@patch("comfy_cli.command.install.execute")
316+
@patch("comfy_cli.cmdline.check_comfy_repo", return_value=(False, None))
317+
@patch("comfy_cli.cmdline.workspace_manager")
318+
@patch("comfy_cli.tracking.prompt_tracking_consent")
319+
def test_cpu_pr_conflict_with_version(self, mock_track, mock_ws, mock_check, mock_execute, runner):
320+
"""Test that --cpu --pr with --version is rejected"""
321+
mock_ws.get_workspace_path.return_value = ("/tmp/test", None)
322+
result = runner.invoke(app, ["--skip-prompt", "install", "--cpu", "--pr", "#123", "--version", "1.0.0"])
323+
324+
assert result.exit_code != 0
325+
assert "--pr cannot be used" in result.stdout
326+
assert not mock_execute.called
327+
328+
@patch("comfy_cli.command.install.execute")
329+
@patch("comfy_cli.cmdline.check_comfy_repo", return_value=(False, None))
330+
@patch("comfy_cli.cmdline.workspace_manager")
331+
@patch("comfy_cli.tracking.prompt_tracking_consent")
332+
def test_cpu_pr_conflict_with_commit(self, mock_track, mock_ws, mock_check, mock_execute, runner):
333+
"""Test that --cpu --pr with --commit is rejected"""
334+
mock_ws.get_workspace_path.return_value = ("/tmp/test", None)
335+
result = runner.invoke(
336+
app, ["--skip-prompt", "install", "--cpu", "--pr", "#123", "--version", "nightly", "--commit", "abc123"]
337+
)
338+
339+
assert result.exit_code != 0
340+
assert "--pr cannot be used" in result.stdout
341+
assert not mock_execute.called
342+
343+
@patch("comfy_cli.command.install.execute")
344+
@patch("comfy_cli.cmdline.check_comfy_repo", return_value=(False, None))
345+
@patch("comfy_cli.cmdline.workspace_manager")
346+
@patch("comfy_cli.tracking.prompt_tracking_consent")
347+
def test_cpu_pr_passes_pr_to_execute(self, mock_track, mock_ws, mock_check, mock_execute, runner):
348+
"""Test that --cpu --pr passes pr parameter to install_inner.execute"""
349+
mock_ws.get_workspace_path.return_value = ("/tmp/test", None)
350+
runner.invoke(app, ["--skip-prompt", "install", "--cpu", "--pr", "#123"])
351+
352+
assert mock_execute.called
353+
call_kwargs = mock_execute.call_args.kwargs
354+
assert call_kwargs.get("pr") == "#123"
355+
315356

316357
class TestPRInfoDataClass:
317358
"""Test PRInfo data class"""

0 commit comments

Comments
 (0)