@@ -195,17 +195,22 @@ def __init__(
195
195
self ._remotes : Union [FullRemoteDict , None ]
196
196
197
197
if remotes is None :
198
- self ._remotes : FullRemoteDict = {"origin" : url }
198
+ self ._remotes : FullRemoteDict = {"origin" : { "fetch" : url , "push" : url } }
199
199
elif isinstance (remotes , dict ):
200
200
self ._remotes : FullRemoteDict = remotes
201
201
for remote_name , url in remotes .items ():
202
- if isinstance (str , dict ):
202
+ if isinstance (url , str ):
203
203
remotes [remote_name ] = {
204
204
"fetch" : url ,
205
205
"push" : url ,
206
206
}
207
207
208
208
BaseRepo .__init__ (self , url , repo_dir , * args , ** kwargs )
209
+ self .url = (
210
+ self ._remotes .get ("origin" )["fetch" ]
211
+ if self ._remotes .get ("origin" )
212
+ else next (iter (self ._remotes .items ()))[1 ]["fetch" ]
213
+ )
209
214
210
215
@classmethod
211
216
def from_pip_url (cls , pip_url , * args , ** kwargs ):
@@ -227,12 +232,17 @@ def set_remotes(self, overwrite: bool = False):
227
232
for remote_name , url in remotes .items ():
228
233
existing_remote = self .remote (remote_name )
229
234
if isinstance (url , dict ) and "fetch" in url :
230
- if not existing_remote or existing_remote .fetch_url != url :
235
+ if not existing_remote or existing_remote .fetch_url != url [ "fetch" ] :
231
236
self .set_remote (
232
237
name = remote_name , url = url ["fetch" ], overwrite = overwrite
233
238
)
239
+ # refresh if we're setting it, so push can be checked
240
+ existing_remote = self .remote (remote_name )
234
241
if "push" in url :
235
- if not existing_remote or existing_remote .push_url != url :
242
+ if (
243
+ not existing_remote
244
+ or existing_remote .push_url != url ["push" ]
245
+ ):
236
246
self .set_remote (
237
247
name = remote_name ,
238
248
url = url ["push" ],
@@ -271,7 +281,7 @@ def update_repo(self, set_remotes: bool = False, *args, **kwargs):
271
281
272
282
if not os .path .isdir (os .path .join (self .path , ".git" )):
273
283
self .obtain ()
274
- self .update_repo ()
284
+ self .update_repo (set_remotes = set_remotes )
275
285
return
276
286
277
287
if set_remotes :
0 commit comments