(url, instant_execution=False, msg_prefix='', no_deps=False)
| 2198 | |
| 2199 | |
| 2200 | async def gitclone_install(url, instant_execution=False, msg_prefix='', no_deps=False): |
| 2201 | await unified_manager.reload('cache') |
| 2202 | await unified_manager.get_custom_nodes('default', 'cache') |
| 2203 | |
| 2204 | print(f"{msg_prefix}Install: {url}") |
| 2205 | |
| 2206 | result = ManagedResult('install-git') |
| 2207 | |
| 2208 | if not is_valid_url(url): |
| 2209 | return result.fail(f"Invalid git url: '{url}'") |
| 2210 | |
| 2211 | if url.endswith("/"): |
| 2212 | url = url[:-1] |
| 2213 | try: |
| 2214 | cnr = unified_manager.get_cnr_by_repo(url) |
| 2215 | if cnr: |
| 2216 | cnr_id = cnr['id'] |
| 2217 | return await unified_manager.install_by_id(cnr_id, version_spec='nightly', channel='default', mode='cache') |
| 2218 | else: |
| 2219 | repo_name = os.path.splitext(os.path.basename(url))[0] |
| 2220 | |
| 2221 | # NOTE: Keep original name as possible if unknown node |
| 2222 | # node_dir = f"{repo_name}@unknown" |
| 2223 | node_dir = repo_name |
| 2224 | |
| 2225 | repo_path = os.path.join(get_default_custom_nodes_path(), node_dir) |
| 2226 | |
| 2227 | if os.path.exists(repo_path): |
| 2228 | return result.fail(f"Already exists: '{repo_path}'") |
| 2229 | |
| 2230 | for custom_nodes_dir in get_custom_nodes_paths(): |
| 2231 | disabled_repo_path1 = os.path.join(custom_nodes_dir, '.disabled', node_dir) |
| 2232 | disabled_repo_path2 = os.path.join(custom_nodes_dir, repo_name+'.disabled') # old style |
| 2233 | |
| 2234 | if os.path.exists(disabled_repo_path1): |
| 2235 | return result.fail(f"Already exists (disabled): '{disabled_repo_path1}'") |
| 2236 | |
| 2237 | if os.path.exists(disabled_repo_path2): |
| 2238 | return result.fail(f"Already exists (disabled): '{disabled_repo_path2}'") |
| 2239 | |
| 2240 | print(f"CLONE into '{repo_path}'") |
| 2241 | |
| 2242 | # Clone the repository from the remote URL |
| 2243 | clone_url = git_utils.get_url_for_clone(url) |
| 2244 | |
| 2245 | if not instant_execution and platform.system() == 'Windows': |
| 2246 | 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()) |
| 2247 | if res != 0: |
| 2248 | return result.fail(f"Failed to clone '{clone_url}' into '{repo_path}'") |
| 2249 | else: |
| 2250 | repo = git.Repo.clone_from(clone_url, repo_path, recursive=True, progress=GitProgress()) |
| 2251 | repo.git.clear_cache() |
| 2252 | repo.close() |
| 2253 | |
| 2254 | execute_install_script(url, repo_path, instant_execution=instant_execution, no_deps=no_deps) |
| 2255 | print("Installation was successful.") |
| 2256 | return result.with_target(repo_path) |
| 2257 |
nothing calls this directly
no test coverage detected