@@ -64,11 +64,11 @@ def extract_repos(config: dict, cwd=pathlib.Path.cwd()) -> list[ConfigDict]:
64
64
-------
65
65
list : List of normalized repository information
66
66
"""
67
- configs = []
67
+ configs : list [ ConfigDict ] = []
68
68
for directory , repos in config .items ():
69
69
for repo , repo_data in repos .items ():
70
70
71
- conf = {}
71
+ conf : ConfigDict = {}
72
72
73
73
"""
74
74
repo_name: http://myrepo.com/repo.git
@@ -96,18 +96,26 @@ def extract_repos(config: dict, cwd=pathlib.Path.cwd()) -> list[ConfigDict]:
96
96
if "parent_dir" not in conf :
97
97
conf ["parent_dir" ] = expand_dir (directory , cwd = cwd )
98
98
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
-
103
99
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
+ )
105
103
106
104
if "remotes" in conf :
107
105
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
+
111
119
configs .append (conf )
112
120
113
121
return configs
@@ -194,7 +202,7 @@ def find_config_files(
194
202
configs .extend (find_config_files (path , match , f ))
195
203
else :
196
204
match = f"{ match } .{ filetype } "
197
- configs = path .glob (match )
205
+ configs = list ( path .glob (match ) )
198
206
199
207
return configs
200
208
@@ -222,6 +230,7 @@ def load_configs(files: list[StrPath], cwd=pathlib.Path.cwd()):
222
230
for file in files :
223
231
if isinstance (file , str ):
224
232
file = pathlib .Path (file )
233
+ assert isinstance (file , pathlib .Path )
225
234
ext = file .suffix .lstrip ("." )
226
235
conf = kaptan .Kaptan (handler = ext ).import_config (str (file ))
227
236
newrepos = extract_repos (conf .export ("dict" ), cwd = cwd )
0 commit comments