66import click .shell_completion
77from click .shell_completion import CompletionItem
88
9- from libvcs .shortcuts import create_project_from_pip_url
9+ from libvcs ._internal .shortcuts import create_project
10+ from libvcs .url import registry as url_tools
11+ from vcspull .types import ConfigDict
1012
1113from ..config import filter_repos , find_config_files , load_configs
1214
@@ -21,13 +23,13 @@ def get_repo_completions(
2123 if ctx .params ["config" ] is None
2224 else load_configs (files = [ctx .params ["config" ]])
2325 )
24- found_repos = []
26+ found_repos : list [ ConfigDict ] = []
2527 repo_terms = [incomplete ]
2628
2729 for repo_term in repo_terms :
2830 dir , vcs_url , name = None , None , None
2931 if any (repo_term .startswith (n ) for n in ["./" , "/" , "~" , "$HOME" ]):
30- dir = repo_term
32+ dir = dir
3133 elif any (repo_term .startswith (n ) for n in ["http" , "git" , "svn" , "hg" ]):
3234 vcs_url = repo_term
3335 else :
@@ -105,9 +107,21 @@ def update_repo(repo_dict):
105107 repo_dict = deepcopy (repo_dict )
106108 if "pip_url" not in repo_dict :
107109 repo_dict ["pip_url" ] = repo_dict .pop ("url" )
110+ if "url" not in repo_dict :
111+ repo_dict ["url" ] = repo_dict .pop ("pip_url" )
108112 repo_dict ["progress_callback" ] = progress_cb
109113
110- r = create_project_from_pip_url (** repo_dict ) # Creates the repo object
114+ if repo_dict .get ("vcs" ) is None :
115+ vcs_matches = url_tools .registry .match (url = repo_dict ["url" ], is_explicit = True )
116+
117+ if len (vcs_matches ) == 0 :
118+ raise Exception (f"No vcs found for { repo_dict } " )
119+ if len (vcs_matches ) > 1 :
120+ raise Exception (f"No exact matches for { repo_dict } " )
121+
122+ repo_dict ["vcs" ] = vcs_matches [0 ].vcs
123+
124+ r = create_project (** repo_dict ) # Creates the repo object
111125 r .update_repo (set_remotes = True ) # Creates repo if not exists and fetches
112126
113127 return r
0 commit comments