@@ -247,7 +247,7 @@ private void InitRepo()
247
247
var repo = _provider . InitVBAProject ( folderPicker . SelectedPath ) ;
248
248
Provider = _providerFactory . CreateProvider ( _vbe . ActiveVBProject , repo , _wrapperFactory ) ;
249
249
250
- AddRepoToConfig ( ( Repository ) repo ) ;
250
+ AddOrUpdateLocalPathConfig ( ( Repository ) repo ) ;
251
251
Status = RubberduckUI . Online ;
252
252
}
253
253
}
@@ -267,10 +267,27 @@ private void SetChildPresenterSourceControlProviders(ISourceControlProvider prov
267
267
}
268
268
}
269
269
270
- private void AddRepoToConfig ( Repository repo )
270
+ private void AddOrUpdateLocalPathConfig ( Repository repo )
271
271
{
272
- _config . Repositories . Add ( repo ) ;
273
- _configService . SaveConfiguration ( _config ) ;
272
+ if ( _config . Repositories . All ( repository => repository . LocalLocation != repo . LocalLocation ) )
273
+ {
274
+ _config . Repositories . Add ( repo ) ;
275
+ _configService . SaveConfiguration ( _config ) ;
276
+ }
277
+ else
278
+ {
279
+ var existing = _config . Repositories . Single ( repository => repository . LocalLocation == repo . LocalLocation ) ;
280
+ if ( string . IsNullOrEmpty ( repo . RemoteLocation ) && ! string . IsNullOrEmpty ( existing . RemoteLocation ) )
281
+ {
282
+ // config already has remote location and correct repository name - nothing to update
283
+ return ;
284
+ }
285
+
286
+ existing . Name = repo . Name ;
287
+ existing . RemoteLocation = repo . RemoteLocation ;
288
+
289
+ _configService . SaveConfiguration ( _config ) ;
290
+ }
274
291
}
275
292
276
293
private void OpenRepo ( )
@@ -295,7 +312,7 @@ private void OpenRepo()
295
312
return ;
296
313
}
297
314
298
- AddRepoToConfig ( repo ) ;
315
+ AddOrUpdateLocalPathConfig ( repo ) ;
299
316
300
317
Status = RubberduckUI . Online ;
301
318
}
@@ -308,7 +325,7 @@ private void CloneRepo()
308
325
_provider = _providerFactory . CreateProvider ( _vbe . ActiveVBProject ) ;
309
326
var repo = _provider . Clone ( RemotePath , LocalDirectory ) ;
310
327
Provider = _providerFactory . CreateProvider ( _vbe . ActiveVBProject , repo , _wrapperFactory ) ;
311
- AddRepoToConfig ( new Repository
328
+ AddOrUpdateLocalPathConfig ( new Repository
312
329
{
313
330
Name = _vbe . ActiveVBProject . Name ,
314
331
LocalLocation = repo . LocalLocation ,
0 commit comments