@@ -195,17 +195,22 @@ def __init__(
195195 self ._remotes : Union [FullRemoteDict , None ]
196196
197197 if remotes is None :
198- self ._remotes : FullRemoteDict = {"origin" : url }
198+ self ._remotes : FullRemoteDict = {"origin" : { "fetch" : url , "push" : url } }
199199 elif isinstance (remotes , dict ):
200200 self ._remotes : FullRemoteDict = remotes
201201 for remote_name , url in remotes .items ():
202- if isinstance (str , dict ):
202+ if isinstance (url , str ):
203203 remotes [remote_name ] = {
204204 "fetch" : url ,
205205 "push" : url ,
206206 }
207207
208208 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+ )
209214
210215 @classmethod
211216 def from_pip_url (cls , pip_url , * args , ** kwargs ):
@@ -227,12 +232,17 @@ def set_remotes(self, overwrite: bool = False):
227232 for remote_name , url in remotes .items ():
228233 existing_remote = self .remote (remote_name )
229234 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" ] :
231236 self .set_remote (
232237 name = remote_name , url = url ["fetch" ], overwrite = overwrite
233238 )
239+ # refresh if we're setting it, so push can be checked
240+ existing_remote = self .remote (remote_name )
234241 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+ ):
236246 self .set_remote (
237247 name = remote_name ,
238248 url = url ["push" ],
@@ -271,7 +281,7 @@ def update_repo(self, set_remotes: bool = False, *args, **kwargs):
271281
272282 if not os .path .isdir (os .path .join (self .path , ".git" )):
273283 self .obtain ()
274- self .update_repo ()
284+ self .update_repo (set_remotes = set_remotes )
275285 return
276286
277287 if set_remotes :
0 commit comments