Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
063e845fc8 |
@@ -67,6 +67,27 @@ and this project adheres to [Semantic Versioning 2.0.0](https://semver.org/spec/
|
||||
|
||||
### Fixed
|
||||
|
||||
- An install by a git URL takes a commit, and a URL with a user. `cm-cli
|
||||
install <url>` and **Install via Git URL** of the legacy UI cloned the whole
|
||||
text as the URL, so `https://host/owner/repo@<commit>` failed, where `main`
|
||||
installs that commit. They now clone the repository and check out what
|
||||
follows the last `@` of the path, a commit, a tag or a branch such as
|
||||
`feature/x`. The `@` of a user is not that one:
|
||||
`git@host:owner/repo.git`, `ssh://git@host/owner/repo.git` and
|
||||
`https://user:token@host/owner/repo.git` are cloned whole, and each takes
|
||||
`@<commit>` after it (#3627, as #3628 for `main`). An install whose commit
|
||||
is not in the repository fails and leaves no clone. With the pygit2 backend,
|
||||
a branch of the repository and a short commit id are checked out as well.
|
||||
|
||||
An SSH URL of a host other than GitHub, `git@host:owner/repo.git`, was
|
||||
cloned from `https://github.com/git@host:owner/repo.git` and failed: a text
|
||||
with one `/` was read as the short `owner/repo` of a GitHub repository. A
|
||||
text with a `:` is no longer read that way. A URL is taken for a GitHub
|
||||
repository by its host: a URL of another host with the word `github` in its
|
||||
user or its path, such as `https://gitlab.example.com/owner/github-tools.git`,
|
||||
was cloned from `https://github.com/owner/github-tools`. A URL of GitHub is
|
||||
still cloned as `https://github.com/<owner>/<repo>`, without its user or its
|
||||
token.
|
||||
- A nightly install over an enabled version of the registry enables that
|
||||
version again when the clone fails. The version was disabled first, and the
|
||||
nodepack was left with no enabled version. This was so for
|
||||
|
||||
+4
-3
@@ -36,6 +36,7 @@ from comfyui_manager.common.git_compat import setup_git_environment
|
||||
from comfyui_manager.common import manager_util
|
||||
from comfyui_manager.common import cm_global
|
||||
from comfyui_manager.legacy import manager_core as core
|
||||
from comfyui_manager.glob import manager_core as glob_core
|
||||
from comfyui_manager.common import context
|
||||
from comfyui_manager.legacy.manager_core import unified_manager
|
||||
from comfyui_manager.common import cnr_utils
|
||||
@@ -193,9 +194,9 @@ class NodeInstallError(Exception):
|
||||
def install_node(node_spec_str, is_all=False, cnt_msg='', **kwargs):
|
||||
raise_on_fail = kwargs.get('raise_on_fail', False)
|
||||
|
||||
if core.is_valid_url(node_spec_str):
|
||||
if glob_core.is_valid_url(node_spec_str):
|
||||
# install via urls
|
||||
res = asyncio.run(core.gitclone_install(node_spec_str, no_deps=cmd_ctx.no_deps))
|
||||
res = asyncio.run(glob_core.gitclone_install(node_spec_str, no_deps=cmd_ctx.no_deps))
|
||||
if not res.result:
|
||||
print(res.msg)
|
||||
print(f"ERROR: An error occurred while installing '{node_spec_str}'.", style="bold red")
|
||||
@@ -1347,7 +1348,7 @@ def install_deps(
|
||||
if state == 'installed':
|
||||
continue
|
||||
elif state == 'not-installed':
|
||||
asyncio.run(core.gitclone_install(k, instant_execution=True, no_deps=bool(uv_compile)))
|
||||
asyncio.run(glob_core.gitclone_install(k, instant_execution=True, no_deps=bool(uv_compile)))
|
||||
else: # disabled
|
||||
cnr = unified_manager.get_cnr_by_repo(k)
|
||||
enable_node(cnr['id'] if cnr else core.unknown_node_id(k))
|
||||
|
||||
@@ -910,16 +910,17 @@ class _Pygit2Repo(GitRepo):
|
||||
return
|
||||
|
||||
try:
|
||||
oid = _pygit2.Oid(hex=ref)
|
||||
obj = self._repo.get(oid)
|
||||
if obj is not None:
|
||||
commit = obj.peel(_pygit2.Commit)
|
||||
self._repo.checkout_tree(self._repo.get(commit.id))
|
||||
self._repo.set_head(commit.id)
|
||||
return
|
||||
commit = self._repo.revparse_single(ref).peel(_pygit2.Commit)
|
||||
self._repo.checkout_tree(self._repo.get(commit.id))
|
||||
self._repo.set_head(commit.id)
|
||||
return
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if self._repo.references.get(f'refs/remotes/origin/{ref}') is not None:
|
||||
self.checkout_new_branch(ref, f'origin/{ref}')
|
||||
return
|
||||
|
||||
raise GitCommandError(f"Cannot resolve ref for checkout: {ref}")
|
||||
|
||||
def checkout_new_branch(self, branch_name, start_point):
|
||||
|
||||
@@ -549,7 +549,7 @@ try:
|
||||
if len(sys.argv) > 4:
|
||||
repo_path = sys.argv[4]
|
||||
|
||||
gitclone(sys.argv[2], sys.argv[3], repo_path=repo_path)
|
||||
gitclone(sys.argv[2], sys.argv[3], target_hash=sys.argv[5] if len(sys.argv) > 5 else None, repo_path=repo_path)
|
||||
elif sys.argv[1] == "--check":
|
||||
gitcheck(sys.argv[2], False)
|
||||
elif sys.argv[1] == "--fetch":
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import os
|
||||
import configparser
|
||||
import logging
|
||||
import re
|
||||
|
||||
|
||||
GITHUB_ENDPOINT = os.getenv('GITHUB_ENDPOINT')
|
||||
@@ -147,12 +148,15 @@ def normalize_url(url) -> str:
|
||||
return url
|
||||
|
||||
|
||||
_HOST_OF_GIT_URL = re.compile(r'^(?:[A-Za-z][A-Za-z0-9+.-]*://)?(?:[^/@]*@)?([^/:]*)')
|
||||
|
||||
|
||||
def normalize_to_github_id(url) -> str:
|
||||
if 'github' in url or (GITHUB_ENDPOINT is not None and GITHUB_ENDPOINT in url):
|
||||
if 'github' in _HOST_OF_GIT_URL.match(url).group(1).lower() or (GITHUB_ENDPOINT is not None and GITHUB_ENDPOINT in url):
|
||||
author = os.path.basename(os.path.dirname(url))
|
||||
|
||||
if author.startswith('git@github.com:'):
|
||||
author = author.split(':')[1]
|
||||
if ':' in author:
|
||||
author = author.rsplit(':', 1)[1]
|
||||
|
||||
repo_name = os.path.basename(url)
|
||||
if repo_name.endswith('.git'):
|
||||
@@ -161,7 +165,7 @@ def normalize_to_github_id(url) -> str:
|
||||
return f"{author}/{repo_name}"
|
||||
|
||||
# Handle short format like "author/repo" (aux_id format)
|
||||
if '/' in url and not url.startswith('http'):
|
||||
if '/' in url and not url.startswith('http') and ':' not in url:
|
||||
parts = url.split('/')
|
||||
if len(parts) == 2 and parts[0] and parts[1]:
|
||||
return url
|
||||
@@ -169,6 +173,19 @@ def normalize_to_github_id(url) -> str:
|
||||
return None
|
||||
|
||||
|
||||
_GIT_URL_BEFORE_PATH = re.compile(r'^(?:[A-Za-z][A-Za-z0-9+.-]*://[^/]*(?:/|$)|[^/@:]+@[^/@:]+:)')
|
||||
|
||||
|
||||
def extract_url_and_commit_id(s):
|
||||
before_path = _GIT_URL_BEFORE_PATH.match(s)
|
||||
path_start = before_path.end() if before_path else 0
|
||||
index = s.rfind('@', path_start)
|
||||
if index == -1:
|
||||
return (s, '')
|
||||
else:
|
||||
return (s[:index], s[index+1:])
|
||||
|
||||
|
||||
def get_url_for_clone(url):
|
||||
url = normalize_url(url)
|
||||
|
||||
|
||||
@@ -2405,13 +2405,6 @@ def is_valid_url(url):
|
||||
return False
|
||||
|
||||
|
||||
def extract_url_and_commit_id(s):
|
||||
index = s.rfind('@')
|
||||
if index == -1:
|
||||
return (s, '')
|
||||
else:
|
||||
return (s[:index], s[index+1:])
|
||||
|
||||
async def gitclone_install(url, instant_execution=False, msg_prefix='', no_deps=False):
|
||||
await unified_manager.reload('cache')
|
||||
await unified_manager.get_custom_nodes('default', 'cache')
|
||||
@@ -2431,7 +2424,7 @@ async def gitclone_install(url, instant_execution=False, msg_prefix='', no_deps=
|
||||
cnr_id = cnr['id']
|
||||
return await unified_manager.install_by_id(cnr_id, version_spec='nightly', channel='default', mode='cache', instant_execution=instant_execution, no_deps=no_deps, repo_url=url)
|
||||
else:
|
||||
new_url, commit_id = extract_url_and_commit_id(url)
|
||||
new_url, commit_id = git_utils.extract_url_and_commit_id(url)
|
||||
if commit_id != "":
|
||||
url = new_url
|
||||
repo_name = os.path.splitext(os.path.basename(url))[0]
|
||||
@@ -2460,18 +2453,26 @@ async def gitclone_install(url, instant_execution=False, msg_prefix='', no_deps=
|
||||
# Clone the repository from the remote URL
|
||||
clone_url = git_utils.get_url_for_clone(url)
|
||||
|
||||
if not instant_execution and platform.system() == 'Windows':
|
||||
res = manager_funcs.run_script([sys.executable, context.git_script_path, "--clone", get_default_custom_nodes_path(), clone_url, repo_path], cwd=get_default_custom_nodes_path())
|
||||
if res != 0:
|
||||
return result.fail(f"Failed to clone '{clone_url}' into '{repo_path}'")
|
||||
else:
|
||||
repo = clone_repo(clone_url, repo_path, progress=GitProgress())
|
||||
if commit_id!= "":
|
||||
repo.checkout(commit_id)
|
||||
repo.submodule_update()
|
||||
cloned = False
|
||||
try:
|
||||
if not instant_execution and platform.system() == 'Windows':
|
||||
res = manager_funcs.run_script([sys.executable, context.git_script_path, "--clone", get_default_custom_nodes_path(), clone_url, repo_path] + ([commit_id] if commit_id else []), cwd=get_default_custom_nodes_path())
|
||||
if res != 0:
|
||||
return result.fail(f"Failed to clone '{clone_url}' into '{repo_path}'")
|
||||
else:
|
||||
repo = clone_repo(clone_url, repo_path, progress=GitProgress())
|
||||
try:
|
||||
if commit_id!= "":
|
||||
repo.checkout(commit_id)
|
||||
repo.submodule_update()
|
||||
|
||||
repo.clear_cache()
|
||||
repo.close()
|
||||
repo.clear_cache()
|
||||
finally:
|
||||
repo.close()
|
||||
cloned = True
|
||||
finally:
|
||||
if not cloned and os.path.exists(repo_path):
|
||||
try_rmtree(url, repo_path)
|
||||
|
||||
execute_install_script(url, repo_path, instant_execution=instant_execution, no_deps=no_deps)
|
||||
print("Installation was successful.")
|
||||
|
||||
@@ -2289,6 +2289,9 @@ async def gitclone_install(url, instant_execution=False, msg_prefix='', no_deps=
|
||||
cnr_id = cnr['id']
|
||||
return await unified_manager.install_by_id(cnr_id, version_spec='nightly', channel='default', mode='cache', instant_execution=instant_execution, no_deps=no_deps, repo_url=url)
|
||||
else:
|
||||
new_url, commit_id = git_utils.extract_url_and_commit_id(url)
|
||||
if commit_id != "":
|
||||
url = new_url
|
||||
repo_name = os.path.splitext(os.path.basename(url))[0]
|
||||
|
||||
# NOTE: Keep original name as possible if unknown node
|
||||
@@ -2315,14 +2318,26 @@ async def gitclone_install(url, instant_execution=False, msg_prefix='', no_deps=
|
||||
# Clone the repository from the remote URL
|
||||
clone_url = git_utils.get_url_for_clone(url)
|
||||
|
||||
if not instant_execution and platform.system() == 'Windows':
|
||||
res = manager_funcs.run_script([sys.executable, context.git_script_path, "--clone", get_default_custom_nodes_path(), clone_url, repo_path], cwd=get_default_custom_nodes_path())
|
||||
if res != 0:
|
||||
return result.fail(f"Failed to clone '{clone_url}' into '{repo_path}'")
|
||||
else:
|
||||
repo = git.Repo.clone_from(clone_url, repo_path, recursive=True, progress=GitProgress())
|
||||
repo.git.clear_cache()
|
||||
repo.close()
|
||||
cloned = False
|
||||
try:
|
||||
if not instant_execution and platform.system() == 'Windows':
|
||||
res = manager_funcs.run_script([sys.executable, context.git_script_path, "--clone", get_default_custom_nodes_path(), clone_url, repo_path] + ([commit_id] if commit_id else []), cwd=get_default_custom_nodes_path())
|
||||
if res != 0:
|
||||
return result.fail(f"Failed to clone '{clone_url}' into '{repo_path}'")
|
||||
else:
|
||||
repo = git.Repo.clone_from(clone_url, repo_path, recursive=True, progress=GitProgress())
|
||||
try:
|
||||
if commit_id != "":
|
||||
repo.git.checkout(commit_id)
|
||||
repo.git.submodule('update', '--init', '--recursive')
|
||||
|
||||
repo.git.clear_cache()
|
||||
finally:
|
||||
repo.close()
|
||||
cloned = True
|
||||
finally:
|
||||
if not cloned and os.path.exists(repo_path):
|
||||
try_rmtree(url, repo_path)
|
||||
|
||||
execute_install_script(url, repo_path, instant_execution=instant_execution, no_deps=no_deps)
|
||||
print("Installation was successful.")
|
||||
|
||||
@@ -44,7 +44,7 @@ def cm_cli(manager, core, monkeypatch): # noqa: F811
|
||||
'app': SimpleNamespace(command=lambda *args, **kwargs: lambda function: function),
|
||||
'typer': typer, 'Annotated': Annotated, 'List': List, 'Optional': Optional, 'asyncio': asyncio, 'os': os, 'sys': sys,
|
||||
'json': json, 'threading': threading, 'concurrent': concurrent,
|
||||
'traceback': traceback, 'core': core,
|
||||
'traceback': traceback, 'core': core, 'glob_core': core,
|
||||
'NodeInstallError': type('NodeInstallError', (Exception,), {}),
|
||||
'cmd_ctx': Mock(no_deps=False, channel='default', mode='cache'), 'unified_manager': manager, 'auto_save_snapshot': AsyncMock(),
|
||||
'manager_util': Mock(), 'context': Mock(), 'comfy_path': '', '_finalize_resolve': Mock(), **more,
|
||||
|
||||
@@ -846,6 +846,65 @@ finally:
|
||||
self.assertEqual(p2['sha'], self.first_sha)
|
||||
self.assertTrue(p2['detached'])
|
||||
|
||||
def test_checkout_branch_of_the_remote_after_a_clone(self):
|
||||
snippet = """
|
||||
import tempfile, shutil
|
||||
dest = tempfile.mkdtemp()
|
||||
try:
|
||||
repo = clone_repo(REPO_PATH, os.path.join(dest, 'cloned'))
|
||||
repo.checkout('feature-branch')
|
||||
print(json.dumps({"sha": repo.head_commit_hexsha, "detached": repo.head_is_detached, "branch": repo.active_branch_name}))
|
||||
repo.close()
|
||||
finally:
|
||||
shutil.rmtree(dest, ignore_errors=True)
|
||||
"""
|
||||
branch_sha = subprocess.run(['git', 'rev-parse', 'feature-branch'], cwd=self.repo_path, capture_output=True, text=True, check=True).stdout.strip()
|
||||
for result in _run_both(snippet, self.repo_path):
|
||||
self.assertEqual(result, {'sha': branch_sha, 'detached': False, 'branch': 'feature-branch'})
|
||||
|
||||
def test_checkout_of_a_name_that_is_a_tag_and_a_branch_of_the_remote_takes_the_tag(self):
|
||||
origin = os.path.join(self._tmpdir, 'tag_and_branch')
|
||||
os.makedirs(origin)
|
||||
|
||||
def git(*args):
|
||||
return subprocess.run(['git', '-c', 'user.name=Test', '-c', 'user.email=test@test.com', *args], cwd=origin, capture_output=True, text=True, check=True).stdout.strip()
|
||||
|
||||
git('init', '-b', 'master')
|
||||
git('commit', '--allow-empty', '-m', 'tagged')
|
||||
git('tag', 'both')
|
||||
tagged = git('rev-parse', 'HEAD')
|
||||
git('checkout', '-b', 'both')
|
||||
git('commit', '--allow-empty', '-m', 'on the branch')
|
||||
git('checkout', 'master')
|
||||
snippet = """
|
||||
import tempfile, shutil
|
||||
dest = tempfile.mkdtemp()
|
||||
try:
|
||||
repo = clone_repo(REPO_PATH, os.path.join(dest, 'cloned'))
|
||||
repo.checkout('both')
|
||||
print(json.dumps({"sha": repo.head_commit_hexsha, "detached": repo.head_is_detached}))
|
||||
repo.close()
|
||||
finally:
|
||||
shutil.rmtree(dest, ignore_errors=True)
|
||||
"""
|
||||
for result in _run_both(snippet, origin):
|
||||
self.assertEqual(result, {'sha': tagged, 'detached': True})
|
||||
|
||||
def test_checkout_by_short_sha(self):
|
||||
snippet = f"""
|
||||
import tempfile, shutil
|
||||
dest = tempfile.mkdtemp()
|
||||
try:
|
||||
repo = clone_repo(REPO_PATH, os.path.join(dest, 'cloned'))
|
||||
repo.checkout({self.first_sha[:8]!r})
|
||||
print(json.dumps({{"sha": repo.head_commit_hexsha, "detached": repo.head_is_detached}}))
|
||||
repo.close()
|
||||
finally:
|
||||
shutil.rmtree(dest, ignore_errors=True)
|
||||
"""
|
||||
for result in _run_both(snippet, self.repo_path):
|
||||
self.assertEqual(result, {'sha': self.first_sha, 'detached': True})
|
||||
|
||||
# === list_remotes fetch routing (pygit2) ===
|
||||
|
||||
def test_list_remotes_fetch_routing_pygit2(self):
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
import asyncio
|
||||
import subprocess
|
||||
from unittest.mock import AsyncMock, Mock
|
||||
|
||||
import pytest
|
||||
|
||||
from _install_flags_testutil import GIT_LOCATION, import_reader
|
||||
|
||||
HOST = 'git.example.invalid'
|
||||
PREFIXES = [f'https://{HOST}/grp/', f'https://user:token@{HOST}/grp/', f'git@{HOST}:grp/', f'ssh://git@{HOST}/grp/']
|
||||
REFS = [('zz-pack.git', 'tip'), ('zz-pack.git@{first}', 'first'), ('zz-pack.git@feature/x', 'branch')]
|
||||
|
||||
|
||||
def git(path, *args):
|
||||
return subprocess.run(['git', '-c', 'user.name=test', '-c', 'user.email=test@example.invalid', *args],
|
||||
cwd=path, check=True, capture_output=True, text=True).stdout.strip()
|
||||
|
||||
|
||||
@pytest.fixture(params=['glob', 'legacy'])
|
||||
def core(request):
|
||||
return import_reader(request.param)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def git_reads_the_folder_of_the_test_for_each_prefix(tmp_path, monkeypatch):
|
||||
for name in GIT_LOCATION:
|
||||
monkeypatch.delenv(name, raising=False)
|
||||
monkeypatch.setenv('GIT_CONFIG_COUNT', str(len(PREFIXES)))
|
||||
for index, prefix in enumerate(PREFIXES):
|
||||
monkeypatch.setenv(f'GIT_CONFIG_KEY_{index}', f'url.{tmp_path}/grp/.insteadOf')
|
||||
monkeypatch.setenv(f'GIT_CONFIG_VALUE_{index}', prefix)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def commits(tmp_path, git_reads_the_folder_of_the_test_for_each_prefix):
|
||||
origin = tmp_path / 'grp' / 'zz-pack.git'
|
||||
origin.mkdir(parents=True)
|
||||
git(origin, 'init', '-q', '-b', 'main')
|
||||
commits = {}
|
||||
for name, branch in (('first', None), ('tip', None), ('branch', 'feature/x')):
|
||||
if branch:
|
||||
git(origin, 'checkout', '-q', '-b', branch)
|
||||
(origin / '__init__.py').write_text(f'# {name}')
|
||||
git(origin, 'add', '.')
|
||||
git(origin, 'commit', '-q', '-m', name)
|
||||
commits[name] = git(origin, 'rev-parse', 'HEAD')
|
||||
git(origin, 'checkout', '-q', 'main')
|
||||
return commits
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def install(core, monkeypatch, tmp_path):
|
||||
nodes = tmp_path / 'custom_nodes'
|
||||
nodes.mkdir()
|
||||
monkeypatch.setattr(core, 'get_default_custom_nodes_path', lambda: str(nodes))
|
||||
monkeypatch.setattr(core, 'get_custom_nodes_paths', lambda: [str(nodes)])
|
||||
monkeypatch.setattr(core, 'execute_install_script', Mock(return_value=True))
|
||||
monkeypatch.setattr(core.unified_manager, 'reload', AsyncMock())
|
||||
monkeypatch.setattr(core.unified_manager, 'get_custom_nodes', AsyncMock(return_value={}))
|
||||
monkeypatch.setattr(core.unified_manager, 'get_cnr_by_repo', lambda url: None)
|
||||
|
||||
def run(url, instant_execution=True):
|
||||
result = asyncio.run(core.gitclone_install(url, instant_execution=instant_execution, no_deps=True))
|
||||
return result.result, {path.name: git(path, 'rev-parse', 'HEAD') for path in nodes.iterdir()}
|
||||
|
||||
return run
|
||||
|
||||
|
||||
@pytest.mark.parametrize('prefix', PREFIXES)
|
||||
@pytest.mark.parametrize('rest, wanted', REFS, ids=[wanted for _, wanted in REFS])
|
||||
def test_git_url_is_installed_at_its_commit(install, commits, prefix, rest, wanted):
|
||||
assert install(prefix + rest.format(**commits)) == (True, {'zz-pack': commits[wanted]})
|
||||
|
||||
|
||||
def test_clone_that_the_helper_script_makes_on_windows_is_at_the_commit(install, commits, core, monkeypatch, tmp_path):
|
||||
monkeypatch.setattr(core.platform, 'system', lambda: 'Windows')
|
||||
(tmp_path / 'folder_paths.py').write_text('')
|
||||
monkeypatch.setenv('COMFYUI_PATH', str(tmp_path))
|
||||
|
||||
assert install(f'https://{HOST}/grp/zz-pack.git@{commits["first"]}', instant_execution=False) == (True, {'zz-pack': commits['first']})
|
||||
|
||||
|
||||
def test_git_url_whose_commit_is_not_there_fails_and_leaves_no_clone(install, commits):
|
||||
assert install(f'https://{HOST}/grp/zz-pack.git@no-such-commit') == (False, {})
|
||||
|
||||
|
||||
def test_clone_that_the_helper_script_makes_on_windows_is_removed_when_the_commit_is_not_there(install, commits, core, monkeypatch, tmp_path):
|
||||
monkeypatch.setattr(core.platform, 'system', lambda: 'Windows')
|
||||
(tmp_path / 'folder_paths.py').write_text('')
|
||||
monkeypatch.setenv('COMFYUI_PATH', str(tmp_path))
|
||||
|
||||
assert install(f'https://{HOST}/grp/zz-pack.git@no-such-commit', instant_execution=False) == (False, {})
|
||||
|
||||
|
||||
def test_user_of_a_git_url_with_no_path_is_not_a_commit(core):
|
||||
assert core.git_utils.extract_url_and_commit_id(f'https://user:token@{HOST}') == (f'https://user:token@{HOST}', '')
|
||||
|
||||
|
||||
GITHUB = 'https://github.com/owner/repo'
|
||||
|
||||
|
||||
@pytest.mark.parametrize('url, clone_url, repository', [
|
||||
('git@gitlab.example.invalid:owner/repo.git', 'git@gitlab.example.invalid:owner/repo.git', 'git@gitlab.example.invalid:owner/repo.git'),
|
||||
('git@gitlab.example.invalid:github/repo.git', 'git@gitlab.example.invalid:github/repo.git', 'git@gitlab.example.invalid:github/repo.git'),
|
||||
('https://gitlab.example.invalid/owner/github-tools.git', 'https://gitlab.example.invalid/owner/github-tools.git', 'https://gitlab.example.invalid/owner/github-tools.git'),
|
||||
('https://github-bot:token@gitlab.example.invalid/owner/repo.git', 'https://github-bot:token@gitlab.example.invalid/owner/repo.git', 'https://github-bot:token@gitlab.example.invalid/owner/repo.git'),
|
||||
('https://user:token@github.com/owner/repo.git', GITHUB, GITHUB),
|
||||
('https://github.com/owner/repo.git', GITHUB, GITHUB),
|
||||
('https://GitHub.com/owner/repo.git', GITHUB, GITHUB),
|
||||
('git@github.com:owner/repo.git', GITHUB, GITHUB),
|
||||
('git@GitHub.com:owner/repo.git', GITHUB, GITHUB),
|
||||
('ssh://git@github.com/owner/repo.git', GITHUB, GITHUB),
|
||||
('owner/repo', GITHUB, GITHUB),
|
||||
])
|
||||
def test_only_a_url_of_a_github_host_is_a_github_repository(core, monkeypatch, url, clone_url, repository):
|
||||
monkeypatch.setattr(core.git_utils, 'GITHUB_ENDPOINT', None)
|
||||
|
||||
assert (core.git_utils.get_url_for_clone(url), core.git_utils.normalize_url(url)) == (clone_url, repository)
|
||||
@@ -26,7 +26,7 @@ def install(node, exit_on_fail):
|
||||
'typer': typer, 'Annotated': Annotated, 'List': List, 'Optional': Optional,
|
||||
'asyncio': asyncio, 'sys': sys, 'traceback': traceback, 'print': lambda *objects, style=None: print(*objects), 'NodeInstallError': NodeInstallError,
|
||||
'cmd_ctx': Mock(no_deps=False), 'comfy_path': '', 'context': Mock(), 'manager_util': Mock(),
|
||||
'core': SimpleNamespace(is_valid_url=lambda spec: False), 'unified_manager': unified_manager,
|
||||
'glob_core': SimpleNamespace(is_valid_url=lambda spec: False), 'unified_manager': unified_manager,
|
||||
})['install']([node], None, None, False, False, None, exit_on_fail)
|
||||
|
||||
|
||||
|
||||
@@ -255,7 +255,7 @@ def test_cm_cli_install_reports_an_enable_that_failed(core, custom_nodes): # no
|
||||
(custom_nodes / 'ComfyUI-Bar').mkdir()
|
||||
out = io.StringIO()
|
||||
install_node = cm_cli_function('install_node', {
|
||||
'asyncio': asyncio, 'core': core, 'unified_manager': manager, 'print': lambda *objects, **kwargs: print(*objects, file=out),
|
||||
'asyncio': asyncio, 'core': core, 'glob_core': core, 'unified_manager': manager, 'print': lambda *objects, **kwargs: print(*objects, file=out),
|
||||
'cmd_ctx': SimpleNamespace(channel=core.DEFAULT_CHANNEL, mode='cache', no_deps=False), 'NodeInstallError': NodeInstallError})
|
||||
|
||||
with pytest.raises(NodeInstallError):
|
||||
|
||||
Reference in New Issue
Block a user