@@ -49,7 +49,9 @@ public void Initialize(IRepositoryManager initRepositoryManager)
4949 repositoryManager = initRepositoryManager ;
5050 repositoryManager . CurrentBranchUpdated += RepositoryManagerOnCurrentBranchUpdated ;
5151 repositoryManager . GitStatusUpdated += RepositoryManagerOnGitStatusUpdated ;
52+ repositoryManager . GitAheadBehindStatusUpdated += RepositoryManagerOnGitAheadBehindStatusUpdated ;
5253 repositoryManager . GitLogUpdated += RepositoryManagerOnGitLogUpdated ;
54+ repositoryManager . GitLocksUpdated += RepositoryManagerOnGitLocksUpdated ;
5355 repositoryManager . LocalBranchesUpdated += RepositoryManagerOnLocalBranchesUpdated ;
5456 repositoryManager . RemoteBranchesUpdated += RepositoryManagerOnRemoteBranchesUpdated ;
5557 }
@@ -267,7 +269,7 @@ private void CacheContainer_OnCacheInvalidated(CacheType cacheType)
267269 break ;
268270
269271 case CacheType . GitLocksCache :
270- repositoryManager ? . UpdateLocks ( ) ;
272+ UpdateLocks ( ) ;
271273 break ;
272274
273275 case CacheType . GitUserCache :
@@ -353,26 +355,36 @@ private void RepositoryManagerOnCurrentBranchUpdated(ConfigBranch? branch, Confi
353355 new ActionTask ( CancellationToken . None , ( ) => {
354356 if ( ! Nullable . Equals ( CurrentConfigBranch , branch ) )
355357 {
356- var currentBranch = branch != null ? ( GitBranch ? ) GetLocalGitBranch ( branch . Value ) : null ;
358+ var currentBranch = branch != null ? ( GitBranch ? ) GetLocalGitBranch ( branch . Value ) : null ;
357359
358- CurrentConfigBranch = branch ;
359- CurrentBranch = currentBranch ;
360- UpdateLocalBranches ( ) ;
360+ CurrentConfigBranch = branch ;
361+ CurrentBranch = currentBranch ;
362+ UpdateLocalBranches ( ) ;
361363 }
362364
363365 if ( ! Nullable . Equals ( CurrentConfigRemote , remote ) )
364366 {
365- CurrentConfigRemote = remote ;
366- CurrentRemote = GetGitRemote ( remote . Value ) ;
367- ClearRepositoryInfo ( ) ;
367+ CurrentConfigRemote = remote ;
368+ CurrentRemote = remote . HasValue ? ( GitRemote ? ) GetGitRemote ( remote . Value ) : null ;
369+ ClearRepositoryInfo ( ) ;
368370 }
369371 } ) { Affinity = TaskAffinity . UI } . Start ( ) ;
370372 }
371373
372374 private void RepositoryManagerOnGitStatusUpdated ( GitStatus gitStatus )
373375 {
374376 new ActionTask ( CancellationToken . None , ( ) => {
375- CurrentStatus = gitStatus ;
377+ CurrentChanges = gitStatus . Entries ;
378+ CurrentAhead = gitStatus . Ahead ;
379+ CurrentBehind = gitStatus . Behind ;
380+ } ) { Affinity = TaskAffinity . UI } . Start ( ) ;
381+ }
382+
383+ private void RepositoryManagerOnGitAheadBehindStatusUpdated ( GitAheadBehindStatus aheadBehindStatus )
384+ {
385+ new ActionTask ( CancellationToken . None , ( ) => {
386+ CurrentAhead = aheadBehindStatus . Ahead ;
387+ CurrentBehind = aheadBehindStatus . Behind ;
376388 } ) { Affinity = TaskAffinity . UI } . Start ( ) ;
377389 }
378390
@@ -383,6 +395,14 @@ private void RepositoryManagerOnGitLogUpdated(List<GitLogEntry> gitLogEntries)
383395 } ) { Affinity = TaskAffinity . UI } . Start ( ) ;
384396 }
385397
398+ private void RepositoryManagerOnGitLocksUpdated ( List < GitLock > gitLocks )
399+ {
400+ new ActionTask ( CancellationToken . None , ( ) => {
401+ CurrentLocks = gitLocks ;
402+ } )
403+ { Affinity = TaskAffinity . UI } . Start ( ) ;
404+ }
405+
386406 private void RepositoryManagerOnRemoteBranchesUpdated ( Dictionary < string , ConfigRemote > remotes ,
387407 Dictionary < string , Dictionary < string , ConfigBranch > > branches )
388408 {
@@ -401,6 +421,14 @@ private void RepositoryManagerOnLocalBranchesUpdated(Dictionary<string, ConfigBr
401421 } ) { Affinity = TaskAffinity . UI } . Start ( ) ;
402422 }
403423
424+ private void UpdateLocks ( )
425+ {
426+ if ( CurrentRemote . HasValue )
427+ {
428+ repositoryManager ? . UpdateLocks ( ) ;
429+ }
430+ }
431+
404432 private void UpdateLocalBranches ( )
405433 {
406434 LocalBranches = LocalConfigBranches . Values . Select ( GetLocalGitBranch ) . ToArray ( ) ;
@@ -469,10 +497,22 @@ private ConfigRemote? CurrentConfigRemote
469497 set { cacheContainer . BranchCache . CurrentConfigRemote = value ; }
470498 }
471499
472- public GitStatus CurrentStatus
500+ public int CurrentAhead
501+ {
502+ get { return cacheContainer . GitStatusCache . Ahead ; }
503+ private set { cacheContainer . GitStatusCache . Ahead = value ; }
504+ }
505+
506+ public int CurrentBehind
507+ {
508+ get { return cacheContainer . GitStatusCache . Behind ; }
509+ private set { cacheContainer . GitStatusCache . Behind = value ; }
510+ }
511+
512+ public List < GitStatusEntry > CurrentChanges
473513 {
474- get { return cacheContainer . GitStatusCache . GitStatus ; }
475- private set { cacheContainer . GitStatusCache . GitStatus = value ; }
514+ get { return cacheContainer . GitStatusCache . Entries ; }
515+ private set { cacheContainer . GitStatusCache . Entries = value ; }
476516 }
477517
478518 public GitBranch ? CurrentBranch
0 commit comments