@@ -20,6 +20,7 @@ class ChangesView : Subview
20
20
21
21
[ NonSerialized ] private bool currentBranchHasUpdate ;
22
22
[ NonSerialized ] private bool currentStatusEntriesHasUpdate ;
23
+ [ NonSerialized ] private bool currentLocksHasUpdate ;
23
24
[ NonSerialized ] private bool isBusy ;
24
25
25
26
[ SerializeField ] private string commitBody = "" ;
@@ -28,7 +29,9 @@ class ChangesView : Subview
28
29
[ SerializeField ] private Vector2 scroll ;
29
30
[ SerializeField ] private CacheUpdateEvent lastCurrentBranchChangedEvent ;
30
31
[ SerializeField ] private CacheUpdateEvent lastStatusEntriesChangedEvent ;
32
+ [ SerializeField ] private CacheUpdateEvent lastLocksChangedEvent ;
31
33
[ SerializeField ] private ChangesTree treeChanges ;
34
+ [ SerializeField ] private HashSet < string > gitLocks ;
32
35
[ SerializeField ] private List < GitStatusEntry > gitStatusEntries ;
33
36
[ SerializeField ] private string changedFilesText = NoChangedFilesLabel ;
34
37
@@ -39,6 +42,7 @@ public override void OnEnable()
39
42
AttachHandlers ( Repository ) ;
40
43
Repository . CheckCurrentBranchChangedEvent ( lastCurrentBranchChangedEvent ) ;
41
44
Repository . CheckStatusEntriesChangedEvent ( lastStatusEntriesChangedEvent ) ;
45
+ Repository . CheckLocksChangedEvent ( lastLocksChangedEvent ) ;
42
46
}
43
47
44
48
public override void OnDisable ( )
@@ -142,6 +146,16 @@ private void RepositoryOnCurrentBranchChanged(CacheUpdateEvent cacheUpdateEvent)
142
146
}
143
147
}
144
148
149
+ private void RepositoryOnLocksChanged ( CacheUpdateEvent cacheUpdateEvent )
150
+ {
151
+ if ( ! lastLocksChangedEvent . Equals ( cacheUpdateEvent ) )
152
+ {
153
+ lastLocksChangedEvent = cacheUpdateEvent ;
154
+ currentLocksHasUpdate = true ;
155
+ Redraw ( ) ;
156
+ }
157
+ }
158
+
145
159
private void AttachHandlers ( IRepository repository )
146
160
{
147
161
if ( repository == null )
@@ -151,6 +165,7 @@ private void AttachHandlers(IRepository repository)
151
165
152
166
repository . CurrentBranchChanged += RepositoryOnCurrentBranchChanged ;
153
167
repository . StatusEntriesChanged += RepositoryOnStatusEntriesChanged ;
168
+ repository . LocksChanged += RepositoryOnLocksChanged ;
154
169
}
155
170
156
171
private void DetachHandlers ( IRepository repository )
@@ -162,6 +177,7 @@ private void DetachHandlers(IRepository repository)
162
177
163
178
repository . CurrentBranchChanged -= RepositoryOnCurrentBranchChanged ;
164
179
repository . StatusEntriesChanged -= RepositoryOnStatusEntriesChanged ;
180
+ repository . LocksChanged -= RepositoryOnLocksChanged ;
165
181
}
166
182
167
183
private void MaybeUpdateData ( )
@@ -172,9 +188,12 @@ private void MaybeUpdateData()
172
188
currentBranch = string . Format ( "[{0}]" , Repository . CurrentBranchName ) ;
173
189
}
174
190
175
- if ( currentStatusEntriesHasUpdate )
191
+ if ( currentStatusEntriesHasUpdate || currentLocksHasUpdate )
176
192
{
177
193
currentStatusEntriesHasUpdate = false ;
194
+ currentLocksHasUpdate = false ;
195
+
196
+ gitLocks = new HashSet < string > ( Repository . CurrentLocks . Select ( gitLock => gitLock . Path ) ) ;
178
197
gitStatusEntries = Repository . CurrentChanges . Where ( x => x . Status != GitFileStatus . Ignored ) . ToList ( ) ;
179
198
180
199
changedFilesText = gitStatusEntries . Count == 0
@@ -200,7 +219,7 @@ private void BuildTree()
200
219
TreeOnEnable ( ) ;
201
220
}
202
221
203
- treeChanges . Load ( gitStatusEntries . Select ( entry => new GitStatusEntryTreeData ( entry ) ) ) ;
222
+ treeChanges . Load ( gitStatusEntries . Select ( entry => new GitStatusEntryTreeData ( entry , gitLocks . Contains ( entry . Path ) ) ) ) ;
204
223
Redraw ( ) ;
205
224
}
206
225
0 commit comments