@@ -20,6 +20,7 @@ class ChangesView : Subview
2020
2121 [ NonSerialized ] private bool currentBranchHasUpdate ;
2222 [ NonSerialized ] private bool currentStatusEntriesHasUpdate ;
23+ [ NonSerialized ] private bool currentLocksHasUpdate ;
2324 [ NonSerialized ] private bool isBusy ;
2425
2526 [ SerializeField ] private string commitBody = "" ;
@@ -28,7 +29,9 @@ class ChangesView : Subview
2829 [ SerializeField ] private Vector2 scroll ;
2930 [ SerializeField ] private CacheUpdateEvent lastCurrentBranchChangedEvent ;
3031 [ SerializeField ] private CacheUpdateEvent lastStatusEntriesChangedEvent ;
32+ [ SerializeField ] private CacheUpdateEvent lastLocksChangedEvent ;
3133 [ SerializeField ] private ChangesTree treeChanges ;
34+ [ SerializeField ] private HashSet < string > gitLocks ;
3235 [ SerializeField ] private List < GitStatusEntry > gitStatusEntries ;
3336 [ SerializeField ] private string changedFilesText = NoChangedFilesLabel ;
3437
@@ -39,6 +42,7 @@ public override void OnEnable()
3942 AttachHandlers ( Repository ) ;
4043 Repository . CheckCurrentBranchChangedEvent ( lastCurrentBranchChangedEvent ) ;
4144 Repository . CheckStatusEntriesChangedEvent ( lastStatusEntriesChangedEvent ) ;
45+ Repository . CheckLocksChangedEvent ( lastLocksChangedEvent ) ;
4246 }
4347
4448 public override void OnDisable ( )
@@ -142,6 +146,16 @@ private void RepositoryOnCurrentBranchChanged(CacheUpdateEvent cacheUpdateEvent)
142146 }
143147 }
144148
149+ private void RepositoryOnLocksChanged ( CacheUpdateEvent cacheUpdateEvent )
150+ {
151+ if ( ! lastLocksChangedEvent . Equals ( cacheUpdateEvent ) )
152+ {
153+ lastLocksChangedEvent = cacheUpdateEvent ;
154+ currentLocksHasUpdate = true ;
155+ Redraw ( ) ;
156+ }
157+ }
158+
145159 private void AttachHandlers ( IRepository repository )
146160 {
147161 if ( repository == null )
@@ -151,6 +165,7 @@ private void AttachHandlers(IRepository repository)
151165
152166 repository . CurrentBranchChanged += RepositoryOnCurrentBranchChanged ;
153167 repository . StatusEntriesChanged += RepositoryOnStatusEntriesChanged ;
168+ repository . LocksChanged += RepositoryOnLocksChanged ;
154169 }
155170
156171 private void DetachHandlers ( IRepository repository )
@@ -162,6 +177,7 @@ private void DetachHandlers(IRepository repository)
162177
163178 repository . CurrentBranchChanged -= RepositoryOnCurrentBranchChanged ;
164179 repository . StatusEntriesChanged -= RepositoryOnStatusEntriesChanged ;
180+ repository . LocksChanged -= RepositoryOnLocksChanged ;
165181 }
166182
167183 private void MaybeUpdateData ( )
@@ -172,9 +188,12 @@ private void MaybeUpdateData()
172188 currentBranch = string . Format ( "[{0}]" , Repository . CurrentBranchName ) ;
173189 }
174190
175- if ( currentStatusEntriesHasUpdate )
191+ if ( currentStatusEntriesHasUpdate || currentLocksHasUpdate )
176192 {
177193 currentStatusEntriesHasUpdate = false ;
194+ currentLocksHasUpdate = false ;
195+
196+ gitLocks = new HashSet < string > ( Repository . CurrentLocks . Select ( gitLock => gitLock . Path ) ) ;
178197 gitStatusEntries = Repository . CurrentChanges . Where ( x => x . Status != GitFileStatus . Ignored ) . ToList ( ) ;
179198
180199 changedFilesText = gitStatusEntries . Count == 0
@@ -200,7 +219,7 @@ private void BuildTree()
200219 TreeOnEnable ( ) ;
201220 }
202221
203- treeChanges . Load ( gitStatusEntries . Select ( entry => new GitStatusEntryTreeData ( entry ) ) ) ;
222+ treeChanges . Load ( gitStatusEntries . Select ( entry => new GitStatusEntryTreeData ( entry , gitLocks . Contains ( entry . Path ) ) ) ) ;
204223 Redraw ( ) ;
205224 }
206225
0 commit comments