@@ -57,6 +57,7 @@ public void Initialize(IRepositoryManager initRepositoryManager)
57
57
repositoryManager . GitLocksUpdated += RepositoryManagerOnGitLocksUpdated ;
58
58
repositoryManager . LocalBranchesUpdated += RepositoryManagerOnLocalBranchesUpdated ;
59
59
repositoryManager . RemoteBranchesUpdated += RepositoryManagerOnRemoteBranchesUpdated ;
60
+ repositoryManager . DataNeedsRefreshing += InvalidateCache ;
60
61
}
61
62
62
63
public void Start ( )
@@ -296,29 +297,31 @@ private void InvalidateCache(CacheType cacheType)
296
297
297
298
switch ( cacheType )
298
299
{
299
- case CacheType . BranchCache :
300
+ case CacheType . Branches :
301
+ repositoryManager ? . UpdateBranches ( ) ;
300
302
break ;
301
303
302
- case CacheType . GitLogCache :
304
+ case CacheType . GitLog :
303
305
repositoryManager ? . UpdateGitLog ( ) ;
304
306
break ;
305
307
306
- case CacheType . GitTrackingStatusCache :
308
+ case CacheType . GitAheadBehind :
307
309
repositoryManager ? . UpdateGitAheadBehindStatus ( ) ;
308
310
break ;
309
311
310
- case CacheType . GitLocksCache :
311
- UpdateLocks ( ) ;
312
+ case CacheType . GitLocks :
313
+ if ( CurrentRemote != null )
314
+ repositoryManager ? . UpdateLocks ( ) ;
312
315
break ;
313
316
314
- case CacheType . GitUserCache :
317
+ case CacheType . GitUser :
315
318
break ;
316
319
317
- case CacheType . RepositoryInfoCache :
320
+ case CacheType . RepositoryInfo :
318
321
repositoryManager ? . UpdateRepositoryInfo ( ) ;
319
322
break ;
320
323
321
- case CacheType . GitStatusEntriesCache :
324
+ case CacheType . GitStatus :
322
325
repositoryManager ? . UpdateGitStatus ( ) ;
323
326
break ;
324
327
@@ -332,30 +335,30 @@ private void CacheContainer_OnCacheUpdated(CacheType cacheType, DateTimeOffset o
332
335
var cacheUpdateEvent = new CacheUpdateEvent { UpdatedTime = offset } ;
333
336
switch ( cacheType )
334
337
{
335
- case CacheType . BranchCache :
338
+ case CacheType . Branches :
336
339
HandleBranchCacheUpdatedEvent ( cacheUpdateEvent ) ;
337
340
break ;
338
341
339
- case CacheType . GitLogCache :
342
+ case CacheType . GitLog :
340
343
HandleGitLogCacheUpdatedEvent ( cacheUpdateEvent ) ;
341
344
break ;
342
345
343
- case CacheType . GitTrackingStatusCache :
346
+ case CacheType . GitAheadBehind :
344
347
HandleGitTrackingStatusCacheUpdatedEvent ( cacheUpdateEvent ) ;
345
348
break ;
346
349
347
- case CacheType . GitLocksCache :
350
+ case CacheType . GitLocks :
348
351
HandleGitLocksCacheUpdatedEvent ( cacheUpdateEvent ) ;
349
352
break ;
350
353
351
- case CacheType . GitUserCache :
354
+ case CacheType . GitUser :
352
355
break ;
353
356
354
- case CacheType . RepositoryInfoCache :
357
+ case CacheType . RepositoryInfo :
355
358
HandleRepositoryInfoCacheUpdatedEvent ( cacheUpdateEvent ) ;
356
359
break ;
357
360
358
- case CacheType . GitStatusEntriesCache :
361
+ case CacheType . GitStatus :
359
362
HandleGitStatusEntriesCacheUpdatedEvent ( cacheUpdateEvent ) ;
360
363
break ;
361
364
@@ -411,15 +414,15 @@ private void RepositoryManagerOnCurrentBranchUpdated(ConfigBranch? branch, Confi
411
414
{
412
415
var currentBranch = branch != null ? ( GitBranch ? ) GetLocalGitBranch ( branch . Value ) : null ;
413
416
414
- CurrentConfigBranch = branch ;
415
- CurrentBranch = currentBranch ;
417
+ cacheContainer . BranchCache . CurrentConfigBranch = branch ;
418
+ cacheContainer . RepositoryInfoCache . CurrentGitBranch = currentBranch ;
416
419
UpdateLocalBranches ( ) ;
417
420
}
418
421
419
422
if ( ! Nullable . Equals ( CurrentConfigRemote , remote ) )
420
423
{
421
- CurrentConfigRemote = remote ;
422
- CurrentRemote = remote . HasValue ? ( GitRemote ? ) GetGitRemote ( remote . Value ) : null ;
424
+ cacheContainer . BranchCache . CurrentConfigRemote = remote ;
425
+ cacheContainer . RepositoryInfoCache . CurrentGitRemote = remote . HasValue ? ( GitRemote ? ) GetGitRemote ( remote . Value ) : null ;
423
426
ClearRepositoryInfo ( ) ;
424
427
}
425
428
} ) { Affinity = TaskAffinity . UI } . Start ( ) ;
@@ -428,31 +431,31 @@ private void RepositoryManagerOnCurrentBranchUpdated(ConfigBranch? branch, Confi
428
431
private void RepositoryManagerOnGitStatusUpdated ( GitStatus gitStatus )
429
432
{
430
433
new ActionTask ( TaskManager . Instance . Token , ( ) => {
431
- CurrentChanges = gitStatus . Entries ;
432
- CurrentAhead = gitStatus . Ahead ;
433
- CurrentBehind = gitStatus . Behind ;
434
+ cacheContainer . GitStatusEntriesCache . Entries = gitStatus . Entries ;
435
+ cacheContainer . GitTrackingStatusCache . Ahead = gitStatus . Ahead ;
436
+ cacheContainer . GitTrackingStatusCache . Behind = gitStatus . Behind ;
434
437
} ) { Affinity = TaskAffinity . UI } . Start ( ) ;
435
438
}
436
439
437
440
private void RepositoryManagerOnGitAheadBehindStatusUpdated ( GitAheadBehindStatus aheadBehindStatus )
438
441
{
439
442
new ActionTask ( TaskManager . Instance . Token , ( ) => {
440
- CurrentAhead = aheadBehindStatus . Ahead ;
441
- CurrentBehind = aheadBehindStatus . Behind ;
443
+ cacheContainer . GitTrackingStatusCache . Ahead = aheadBehindStatus . Ahead ;
444
+ cacheContainer . GitTrackingStatusCache . Behind = aheadBehindStatus . Behind ;
442
445
} ) { Affinity = TaskAffinity . UI } . Start ( ) ;
443
446
}
444
447
445
448
private void RepositoryManagerOnGitLogUpdated ( List < GitLogEntry > gitLogEntries )
446
449
{
447
450
new ActionTask ( TaskManager . Instance . Token , ( ) => {
448
- CurrentLog = gitLogEntries ;
451
+ cacheContainer . GitLogCache . Log = gitLogEntries ;
449
452
} ) { Affinity = TaskAffinity . UI } . Start ( ) ;
450
453
}
451
454
452
455
private void RepositoryManagerOnGitLocksUpdated ( List < GitLock > gitLocks )
453
456
{
454
457
new ActionTask ( TaskManager . Instance . Token , ( ) => {
455
- CurrentLocks = gitLocks ;
458
+ cacheContainer . GitLocksCache . GitLocks = gitLocks ;
456
459
} )
457
460
{ Affinity = TaskAffinity . UI } . Start ( ) ;
458
461
}
@@ -462,8 +465,8 @@ private void RepositoryManagerOnRemoteBranchesUpdated(Dictionary<string, ConfigR
462
465
{
463
466
new ActionTask ( TaskManager . Instance . Token , ( ) => {
464
467
cacheContainer . BranchCache . SetRemotes ( remotes , branches ) ;
465
- Remotes = ConfigRemotes . Values . Select ( GetGitRemote ) . ToArray ( ) ;
466
- RemoteBranches = RemoteConfigBranches . Values . SelectMany ( x => x . Values ) . Select ( GetRemoteGitBranch ) . ToArray ( ) ;
468
+ cacheContainer . BranchCache . Remotes = ConfigRemotes . Values . Select ( GetGitRemote ) . ToArray ( ) ;
469
+ cacheContainer . BranchCache . RemoteBranches = RemoteConfigBranches . Values . SelectMany ( x => x . Values ) . Select ( GetRemoteGitBranch ) . ToArray ( ) ;
467
470
} ) { Affinity = TaskAffinity . UI } . Start ( ) ;
468
471
}
469
472
@@ -475,17 +478,9 @@ private void RepositoryManagerOnLocalBranchesUpdated(Dictionary<string, ConfigBr
475
478
} ) { Affinity = TaskAffinity . UI } . Start ( ) ;
476
479
}
477
480
478
- private void UpdateLocks ( )
479
- {
480
- if ( CurrentRemote . HasValue )
481
- {
482
- repositoryManager ? . UpdateLocks ( ) ;
483
- }
484
- }
485
-
486
481
private void UpdateLocalBranches ( )
487
482
{
488
- LocalBranches = LocalConfigBranches . Values . Select ( GetLocalGitBranch ) . ToArray ( ) ;
483
+ cacheContainer . BranchCache . LocalBranches = LocalConfigBranches . Values . Select ( GetLocalGitBranch ) . ToArray ( ) ;
489
484
}
490
485
491
486
private void ClearRepositoryInfo ( )
@@ -521,80 +516,20 @@ private static GitRemote GetGitRemote(ConfigRemote configRemote)
521
516
522
517
private ILocalConfigBranchDictionary LocalConfigBranches => cacheContainer . BranchCache . LocalConfigBranches ;
523
518
524
- public GitRemote [ ] Remotes
525
- {
526
- get { return cacheContainer . BranchCache . Remotes ; }
527
- private set { cacheContainer . BranchCache . Remotes = value ; }
528
- }
529
-
530
- public GitBranch [ ] LocalBranches
531
- {
532
- get { return cacheContainer . BranchCache . LocalBranches ; }
533
- private set { cacheContainer . BranchCache . LocalBranches = value ; }
534
- }
535
-
536
- public GitBranch [ ] RemoteBranches
537
- {
538
- get { return cacheContainer . BranchCache . RemoteBranches ; }
539
- private set { cacheContainer . BranchCache . RemoteBranches = value ; }
540
- }
541
-
542
- private ConfigBranch ? CurrentConfigBranch
543
- {
544
- get { return this . cacheContainer . BranchCache . CurrentConfigBranch ; }
545
- set { cacheContainer . BranchCache . CurrentConfigBranch = value ; }
546
- }
547
-
548
- private ConfigRemote ? CurrentConfigRemote
549
- {
550
- get { return this . cacheContainer . BranchCache . CurrentConfigRemote ; }
551
- set { cacheContainer . BranchCache . CurrentConfigRemote = value ; }
552
- }
553
-
554
- public int CurrentAhead
555
- {
556
- get { return cacheContainer . GitTrackingStatusCache . Ahead ; }
557
- private set { cacheContainer . GitTrackingStatusCache . Ahead = value ; }
558
- }
559
-
560
- public int CurrentBehind
561
- {
562
- get { return cacheContainer . GitTrackingStatusCache . Behind ; }
563
- private set { cacheContainer . GitTrackingStatusCache . Behind = value ; }
564
- }
565
-
566
- public List < GitStatusEntry > CurrentChanges
567
- {
568
- get { return cacheContainer . GitStatusEntriesCache . Entries ; }
569
- private set { cacheContainer . GitStatusEntriesCache . Entries = value ; }
570
- }
571
-
572
- public GitBranch ? CurrentBranch
573
- {
574
- get { return cacheContainer . RepositoryInfoCache . CurrentGitBranch ; }
575
- private set { cacheContainer . RepositoryInfoCache . CurrentGitBranch = value ; }
576
- }
577
-
519
+ public GitRemote [ ] Remotes => cacheContainer . BranchCache . Remotes ;
520
+ public GitBranch [ ] LocalBranches => cacheContainer . BranchCache . LocalBranches ;
521
+ public GitBranch [ ] RemoteBranches => cacheContainer . BranchCache . RemoteBranches ;
522
+ private ConfigBranch ? CurrentConfigBranch => cacheContainer . BranchCache . CurrentConfigBranch ;
523
+ private ConfigRemote ? CurrentConfigRemote => cacheContainer . BranchCache . CurrentConfigRemote ;
524
+ public int CurrentAhead => cacheContainer . GitTrackingStatusCache . Ahead ;
525
+ public int CurrentBehind => cacheContainer . GitTrackingStatusCache . Behind ;
526
+ public List < GitStatusEntry > CurrentChanges => cacheContainer . GitStatusEntriesCache . Entries ;
527
+ public GitBranch ? CurrentBranch => cacheContainer . RepositoryInfoCache . CurrentGitBranch ;
578
528
public string CurrentBranchName => CurrentConfigBranch ? . Name ;
579
529
580
- public GitRemote ? CurrentRemote
581
- {
582
- get { return cacheContainer . RepositoryInfoCache . CurrentGitRemote ; }
583
- private set { cacheContainer . RepositoryInfoCache . CurrentGitRemote = value ; }
584
- }
585
-
586
- public List < GitLogEntry > CurrentLog
587
- {
588
- get { return cacheContainer . GitLogCache . Log ; }
589
- private set { cacheContainer . GitLogCache . Log = value ; }
590
- }
591
-
592
- public List < GitLock > CurrentLocks
593
- {
594
- get { return cacheContainer . GitLocksCache . GitLocks ; }
595
- private set { cacheContainer . GitLocksCache . GitLocks = value ; }
596
- }
597
-
530
+ public GitRemote ? CurrentRemote => cacheContainer . RepositoryInfoCache . CurrentGitRemote ;
531
+ public List < GitLogEntry > CurrentLog => cacheContainer . GitLogCache . Log ;
532
+ public List < GitLock > CurrentLocks => cacheContainer . GitLocksCache . GitLocks ;
598
533
public UriString CloneUrl
599
534
{
600
535
get
0 commit comments