@@ -64,11 +64,11 @@ def extract_repos(config: dict, cwd=pathlib.Path.cwd()) -> list[ConfigDict]:
6464 -------
6565 list : List of normalized repository information
6666 """
67- configs = []
67+ configs : list [ ConfigDict ] = []
6868 for directory , repos in config .items ():
6969 for repo , repo_data in repos .items ():
7070
71- conf = {}
71+ conf : ConfigDict = {}
7272
7373 """
7474 repo_name: http://myrepo.com/repo.git
@@ -96,18 +96,26 @@ def extract_repos(config: dict, cwd=pathlib.Path.cwd()) -> list[ConfigDict]:
9696 if "parent_dir" not in conf :
9797 conf ["parent_dir" ] = expand_dir (directory , cwd = cwd )
9898
99- # repo_dir -> dir in libvcs 0.12.0b25
100- if "repo_dir" in conf and "dir" not in conf :
101- conf ["dir" ] = conf .pop ("repo_dir" )
102-
10399 if "dir" not in conf :
104- conf ["dir" ] = expand_dir (conf ["parent_dir" ] / conf ["name" ], cwd )
100+ conf ["dir" ] = expand_dir (
101+ pathlib .Path (conf ["parent_dir" ]) / conf ["name" ], cwd
102+ )
105103
106104 if "remotes" in conf :
107105 for remote_name , url in conf ["remotes" ].items ():
108- conf ["remotes" ][remote_name ] = GitRemote (
109- name = remote_name , fetch_url = url , push_url = url
110- )
106+ if isinstance (url , GitRemote ):
107+ continue
108+ if isinstance (url , str ):
109+ conf ["remotes" ][remote_name ] = GitRemote (
110+ name = remote_name , fetch_url = url , push_url = url
111+ )
112+ elif isinstance (url , dict ):
113+ assert "push_url" in url
114+ assert "fetch_url" in url
115+ conf ["remotes" ][remote_name ] = GitRemote (
116+ name = remote_name , ** url
117+ )
118+
111119 configs .append (conf )
112120
113121 return configs
@@ -194,7 +202,7 @@ def find_config_files(
194202 configs .extend (find_config_files (path , match , f ))
195203 else :
196204 match = f"{ match } .{ filetype } "
197- configs = path .glob (match )
205+ configs = list ( path .glob (match ) )
198206
199207 return configs
200208
@@ -222,6 +230,7 @@ def load_configs(files: list[StrPath], cwd=pathlib.Path.cwd()):
222230 for file in files :
223231 if isinstance (file , str ):
224232 file = pathlib .Path (file )
233+ assert isinstance (file , pathlib .Path )
225234 ext = file .suffix .lstrip ("." )
226235 conf = kaptan .Kaptan (handler = ext ).import_config (str (file ))
227236 newrepos = extract_repos (conf .export ("dict" ), cwd = cwd )
0 commit comments