@@ -145,13 +145,21 @@ public ITask ReleaseLock(string file, bool force)
145
145
return repositoryManager . UnlockFile ( file , force ) ;
146
146
}
147
147
148
- private void SetCloneUrl ( )
148
+ private void UpdateRepositoryInfo ( )
149
149
{
150
150
if ( CurrentRemote . HasValue )
151
+ {
151
152
CloneUrl = new UriString ( CurrentRemote . Value . Url ) ;
153
+ Name = CloneUrl . RepositoryName ;
154
+ Logger . Trace ( "CloneUrl: {0}" , CloneUrl . ToString ( ) ) ;
155
+ }
152
156
else
157
+ {
153
158
CloneUrl = null ;
154
- Name = CloneUrl != null ? CloneUrl . RepositoryName : LocalPath . FileName ;
159
+ Name = LocalPath . FileName ;
160
+ Logger . Trace ( "CloneUrl: [NULL]" ) ;
161
+ }
162
+
155
163
OnRepositoryInfoChanged ? . Invoke ( ) ;
156
164
}
157
165
@@ -204,7 +212,11 @@ private void UpdateCurrentBranchAndRemote()
204
212
205
213
if ( ! remote . HasValue )
206
214
{
207
- remote = repositoryManager . Config . GetRemotes ( ) . FirstOrDefault ( ) ;
215
+ var configRemotes = repositoryManager . Config . GetRemotes ( ) . ToArray ( ) ;
216
+ if ( configRemotes . Any ( ) )
217
+ {
218
+ remote = configRemotes . FirstOrDefault ( ) ;
219
+ }
208
220
}
209
221
210
222
CurrentRemote = remote ;
@@ -334,8 +346,8 @@ public ConfigBranch? CurrentBranch
334
346
if ( ! Nullable . Equals ( currentBranch , value ) )
335
347
{
336
348
currentBranch = value ;
337
- Logger . Trace ( "OnCurrentBranchChanged: {0}" , value ? . ToString ( ) ?? " NULL") ;
338
- OnCurrentBranchChanged ? . Invoke ( CurrentBranch . HasValue ? CurrentBranch . Value . Name : null ) ;
349
+ Logger . Trace ( "OnCurrentBranchChanged: {0}" , currentBranch . HasValue ? currentBranch . ToString ( ) : "[ NULL] ") ;
350
+ OnCurrentBranchChanged ? . Invoke ( currentBranch . HasValue ? currentBranch . Value . Name : null ) ;
339
351
}
340
352
}
341
353
}
@@ -356,9 +368,9 @@ public ConfigRemote? CurrentRemote
356
368
if ( ! Nullable . Equals ( currentRemote , value ) )
357
369
{
358
370
currentRemote = value ;
359
- SetCloneUrl ( ) ;
360
- Logger . Trace ( " OnCurrentRemoteChanged: {0}" , value ? . ToString ( ) ?? "NULL" ) ;
361
- OnCurrentRemoteChanged ? . Invoke ( CurrentRemote . HasValue ? CurrentRemote . Value . Name : null ) ;
371
+ Logger . Trace ( "OnCurrentRemoteChanged: {0}" , currentRemote . HasValue ? currentRemote . Value . ToString ( ) : "[NULL]" ) ;
372
+ OnCurrentRemoteChanged ? . Invoke ( currentRemote . HasValue ? currentRemote . Value . Name : null ) ;
373
+ UpdateRepositoryInfo ( ) ;
362
374
}
363
375
}
364
376
}
0 commit comments