@@ -15,12 +15,6 @@ class Repository : IEquatable<Repository>, IRepository
15
15
private UriString cloneUrl ;
16
16
private string name ;
17
17
18
- public event Action < CacheUpdateEvent > GitStatusCacheUpdated ;
19
- public event Action < CacheUpdateEvent > GitLogCacheUpdated ;
20
- public event Action < CacheUpdateEvent > GitLockCacheUpdated ;
21
- public event Action < CacheUpdateEvent > BranchCacheUpdated ;
22
- public event Action < CacheUpdateEvent > RepositoryInfoCacheUpdated ;
23
-
24
18
/// <summary>
25
19
/// Initializes a new instance of the <see cref="Repository"/> class.
26
20
/// </summary>
@@ -64,64 +58,69 @@ private void CacheContainer_OnCacheInvalidated(CacheType cacheType)
64
58
65
59
private void CacheContainer_OnCacheUpdated ( CacheType cacheType , DateTimeOffset offset )
66
60
{
61
+ var cacheUpdateEvent = new CacheUpdateEvent { UpdatedTimeString = offset . ToString ( ) } ;
67
62
switch ( cacheType )
68
63
{
69
64
case CacheType . BranchCache :
70
- FireBranchCacheUpdated ( offset ) ;
65
+ HandleBranchCacheUpdatedEvent ( cacheUpdateEvent ) ;
71
66
break ;
72
67
73
68
case CacheType . GitLogCache :
74
- FireGitLogCacheUpdated ( offset ) ;
69
+ HandleGitLogCacheUpdatedEvent ( cacheUpdateEvent ) ;
75
70
break ;
76
71
77
72
case CacheType . GitStatusCache :
78
- FireGitStatusCacheUpdated ( offset ) ;
73
+ HandleGitStatucCacheUpdatedEvent ( cacheUpdateEvent ) ;
79
74
break ;
80
75
81
76
case CacheType . GitLocksCache :
82
- FireGitLocksCacheUpdated ( offset ) ;
77
+ HandleGitLocksCacheUpdatedEvent ( cacheUpdateEvent ) ;
83
78
break ;
84
79
85
80
case CacheType . GitUserCache :
86
81
break ;
87
82
88
83
case CacheType . RepositoryInfoCache :
89
- FireRepositoryInfoCacheUpdated ( offset ) ;
84
+ HandleRepositoryInfoCacheUpdatedEvent ( cacheUpdateEvent ) ;
90
85
break ;
91
86
92
87
default :
93
88
throw new ArgumentOutOfRangeException ( nameof ( cacheType ) , cacheType , null ) ;
94
89
}
95
90
}
96
91
97
- private void FireGitLogCacheUpdated ( DateTimeOffset dateTimeOffset )
92
+ private void HandleRepositoryInfoCacheUpdatedEvent ( CacheUpdateEvent cacheUpdateEvent )
98
93
{
99
- Logger . Trace ( "GitLogCacheUpdated {0}" , dateTimeOffset ) ;
100
- GitLogCacheUpdated ? . Invoke ( new CacheUpdateEvent { UpdatedTimeString = dateTimeOffset . ToString ( ) } ) ;
94
+ Logger . Trace ( "RepositoryInfoCache Updated {0}" , cacheUpdateEvent . UpdatedTimeString ) ;
95
+ CurrentBranchChanged ? . Invoke ( cacheUpdateEvent ) ;
96
+ CurrentRemoteChanged ? . Invoke ( cacheUpdateEvent ) ;
97
+ CurrentBranchAndRemoteChanged ? . Invoke ( cacheUpdateEvent ) ;
101
98
}
102
99
103
- private void FireBranchCacheUpdated ( DateTimeOffset dateTimeOffset )
100
+ private void HandleGitLocksCacheUpdatedEvent ( CacheUpdateEvent cacheUpdateEvent )
104
101
{
105
- Logger . Trace ( "BranchCacheUpdated {0}" , dateTimeOffset ) ;
106
- BranchCacheUpdated ? . Invoke ( new CacheUpdateEvent { UpdatedTimeString = dateTimeOffset . ToString ( ) } ) ;
102
+ Logger . Trace ( "GitLocksCache Updated {0}" , cacheUpdateEvent . UpdatedTimeString ) ;
103
+ LocksChanged ? . Invoke ( cacheUpdateEvent ) ;
107
104
}
108
105
109
- private void FireGitStatusCacheUpdated ( DateTimeOffset dateTimeOffset )
106
+ private void HandleGitStatucCacheUpdatedEvent ( CacheUpdateEvent cacheUpdateEvent )
110
107
{
111
- Logger . Trace ( "GitStatusCacheUpdated {0}" , dateTimeOffset ) ;
112
- GitStatusCacheUpdated ? . Invoke ( new CacheUpdateEvent { UpdatedTimeString = dateTimeOffset . ToString ( ) } ) ;
108
+ Logger . Trace ( "GitStatusCache Updated {0}" , cacheUpdateEvent . UpdatedTimeString ) ;
109
+ StatusChanged ? . Invoke ( cacheUpdateEvent ) ;
113
110
}
114
111
115
- private void FireGitLocksCacheUpdated ( DateTimeOffset dateTimeOffset )
112
+ private void HandleGitLogCacheUpdatedEvent ( CacheUpdateEvent cacheUpdateEvent )
116
113
{
117
- Logger . Trace ( "GitStatusCacheUpdated {0}" , dateTimeOffset ) ;
118
- GitLockCacheUpdated ? . Invoke ( new CacheUpdateEvent { UpdatedTimeString = dateTimeOffset . ToString ( ) } ) ;
114
+ Logger . Trace ( "GitLogCache Updated {0}" , cacheUpdateEvent . UpdatedTimeString ) ;
115
+ LogChanged ? . Invoke ( cacheUpdateEvent ) ;
119
116
}
120
117
121
- private void FireRepositoryInfoCacheUpdated ( DateTimeOffset dateTimeOffset )
118
+ private void HandleBranchCacheUpdatedEvent ( CacheUpdateEvent cacheUpdateEvent )
122
119
{
123
- Logger . Trace ( "RepositoryInfoCacheUpdated {0}" , dateTimeOffset ) ;
124
- RepositoryInfoCacheUpdated ? . Invoke ( new CacheUpdateEvent { UpdatedTimeString = dateTimeOffset . ToString ( ) } ) ;
120
+ Logger . Trace ( "BranchCache Updated {0}" , cacheUpdateEvent . UpdatedTimeString ) ;
121
+ LocalBranchListChanged ? . Invoke ( cacheUpdateEvent ) ;
122
+ RemoteBranchListChanged ? . Invoke ( cacheUpdateEvent ) ;
123
+ LocalAndRemoteBranchListChanged ? . Invoke ( cacheUpdateEvent ) ;
125
124
}
126
125
127
126
public void Initialize ( IRepositoryManager initRepositoryManager )
@@ -202,73 +201,114 @@ public ITask ReleaseLock(string file, bool force)
202
201
return repositoryManager . UnlockFile ( file , force ) . Then ( UpdateLocks ) ;
203
202
}
204
203
205
- public void CheckRepositoryInfoCacheEvent ( CacheUpdateEvent cacheUpdateEvent )
204
+ public void CheckLogChangedEvent ( CacheUpdateEvent cacheUpdateEvent )
206
205
{
207
- var managedCache = cacheContainer . RepositoryInfoCache ;
206
+ var managedCache = cacheContainer . GitLogCache ;
208
207
var raiseEvent = ShouldRaiseCacheEvent ( cacheUpdateEvent , managedCache ) ;
209
208
210
- Logger . Trace ( "CheckRepositoryInfoCacheEvent Current:{0} Check:{1} Result:{2}" , managedCache . LastUpdatedAt ,
209
+ Logger . Trace ( "Check GitLogCache CacheUpdateEvent Current:{0} Check:{1} Result:{2}" , managedCache . LastUpdatedAt ,
211
210
cacheUpdateEvent . UpdatedTimeString ?? "[NULL]" , raiseEvent ) ;
212
211
213
212
if ( raiseEvent )
214
213
{
215
- FireBranchCacheUpdated ( managedCache . LastUpdatedAt ) ;
214
+ var dateTimeOffset = managedCache . LastUpdatedAt ;
215
+ var updateEvent = new CacheUpdateEvent { UpdatedTimeString = dateTimeOffset . ToString ( ) } ;
216
+ HandleGitLogCacheUpdatedEvent ( updateEvent ) ;
216
217
}
217
218
}
218
219
219
- public void CheckBranchCacheEvent ( CacheUpdateEvent cacheUpdateEvent )
220
+ public void CheckStatusChangedEvent ( CacheUpdateEvent cacheUpdateEvent )
220
221
{
221
- var managedCache = cacheContainer . BranchCache ;
222
+ var managedCache = cacheContainer . GitStatusCache ;
222
223
var raiseEvent = ShouldRaiseCacheEvent ( cacheUpdateEvent , managedCache ) ;
223
224
224
- Logger . Trace ( "CheckBranchCacheEvent Current:{0} Check:{1} Result:{2}" , managedCache . LastUpdatedAt ,
225
+ Logger . Trace ( "Check GitStatusCache CacheUpdateEvent Current:{0} Check:{1} Result:{2}" , managedCache . LastUpdatedAt ,
225
226
cacheUpdateEvent . UpdatedTimeString ?? "[NULL]" , raiseEvent ) ;
226
227
227
228
if ( raiseEvent )
228
229
{
229
- FireBranchCacheUpdated ( managedCache . LastUpdatedAt ) ;
230
+ var dateTimeOffset = managedCache . LastUpdatedAt ;
231
+ var updateEvent = new CacheUpdateEvent { UpdatedTimeString = dateTimeOffset . ToString ( ) } ;
232
+ HandleGitStatucCacheUpdatedEvent ( updateEvent ) ;
230
233
}
231
234
}
232
235
233
- public void CheckGitStatusCacheEvent ( CacheUpdateEvent cacheUpdateEvent )
236
+ public void CheckCurrentBranchChangedEvent ( CacheUpdateEvent cacheUpdateEvent )
234
237
{
235
- var managedCache = cacheContainer . GitStatusCache ;
238
+ CheckRepositoryInfoCacheEvent ( cacheUpdateEvent ) ;
239
+ }
240
+
241
+ public void CheckCurrentRemoteChangedEvent ( CacheUpdateEvent cacheUpdateEvent )
242
+ {
243
+ CheckRepositoryInfoCacheEvent ( cacheUpdateEvent ) ;
244
+ }
245
+
246
+ public void CheckCurrentBranchAndRemoteChangedEvent ( CacheUpdateEvent cacheUpdateEvent )
247
+ {
248
+ CheckRepositoryInfoCacheEvent ( cacheUpdateEvent ) ;
249
+ }
250
+
251
+ private void CheckRepositoryInfoCacheEvent ( CacheUpdateEvent cacheUpdateEvent )
252
+ {
253
+ var managedCache = cacheContainer . RepositoryInfoCache ;
236
254
var raiseEvent = ShouldRaiseCacheEvent ( cacheUpdateEvent , managedCache ) ;
237
255
238
- Logger . Trace ( "CheckGitStatusCacheEvent Current:{0} Check:{1} Result:{2}" , managedCache . LastUpdatedAt ,
256
+ Logger . Trace ( "Check RepositoryInfoCache CacheUpdateEvent Current:{0} Check:{1} Result:{2}" , managedCache . LastUpdatedAt ,
239
257
cacheUpdateEvent . UpdatedTimeString ?? "[NULL]" , raiseEvent ) ;
240
258
241
259
if ( raiseEvent )
242
260
{
243
- FireGitStatusCacheUpdated ( managedCache . LastUpdatedAt ) ;
261
+ var dateTimeOffset = managedCache . LastUpdatedAt ;
262
+ var updateEvent = new CacheUpdateEvent { UpdatedTimeString = dateTimeOffset . ToString ( ) } ;
263
+ HandleRepositoryInfoCacheUpdatedEvent ( updateEvent ) ;
244
264
}
245
265
}
246
266
247
- public void CheckGitLogCacheEvent ( CacheUpdateEvent cacheUpdateEvent )
267
+ public void CheckLocksChangedEvent ( CacheUpdateEvent cacheUpdateEvent )
248
268
{
249
- var managedCache = cacheContainer . GitLogCache ;
250
- var raiseEvent = ShouldRaiseCacheEvent ( cacheUpdateEvent , managedCache ) ;
269
+ CacheUpdateEvent cacheUpdateEvent1 = cacheUpdateEvent ;
270
+ var managedCache = cacheContainer . GitLocksCache ;
271
+ var raiseEvent = ShouldRaiseCacheEvent ( cacheUpdateEvent1 , managedCache ) ;
251
272
252
- Logger . Trace ( "CheckGitLogCacheEvent Current:{0} Check:{1} Result:{2}" , managedCache . LastUpdatedAt ,
253
- cacheUpdateEvent . UpdatedTimeString ?? "[NULL]" , raiseEvent ) ;
273
+ Logger . Trace ( "Check GitLocksCache CacheUpdateEvent Current:{0} Check:{1} Result:{2}" , managedCache . LastUpdatedAt ,
274
+ cacheUpdateEvent1 . UpdatedTimeString ?? "[NULL]" , raiseEvent ) ;
254
275
255
276
if ( raiseEvent )
256
277
{
257
- FireGitLogCacheUpdated ( managedCache . LastUpdatedAt ) ;
278
+ var dateTimeOffset = managedCache . LastUpdatedAt ;
279
+ var updateEvent = new CacheUpdateEvent { UpdatedTimeString = dateTimeOffset . ToString ( ) } ;
280
+ HandleGitLocksCacheUpdatedEvent ( updateEvent ) ;
258
281
}
259
282
}
260
283
261
- public void CheckGitLocksCacheEvent ( CacheUpdateEvent cacheUpdateEvent )
284
+ public void CheckLocalBranchListChangedEvent ( CacheUpdateEvent cacheUpdateEvent )
262
285
{
263
- var managedCache = cacheContainer . GitLocksCache ;
286
+ CheckBranchCacheEvent ( cacheUpdateEvent ) ;
287
+ }
288
+
289
+ public void CheckRemoteBranchListChangedEvent ( CacheUpdateEvent cacheUpdateEvent )
290
+ {
291
+ CheckBranchCacheEvent ( cacheUpdateEvent ) ;
292
+ }
293
+
294
+ public void CheckLocalAndRemoteBranchListChangedEvent ( CacheUpdateEvent cacheUpdateEvent )
295
+ {
296
+ CheckBranchCacheEvent ( cacheUpdateEvent ) ;
297
+ }
298
+
299
+ private void CheckBranchCacheEvent ( CacheUpdateEvent cacheUpdateEvent )
300
+ {
301
+ var managedCache = cacheContainer . BranchCache ;
264
302
var raiseEvent = ShouldRaiseCacheEvent ( cacheUpdateEvent , managedCache ) ;
265
303
266
- Logger . Trace ( "CheckGitLocksCacheEvent Current:{0} Check:{1} Result:{2}" , managedCache . LastUpdatedAt ,
304
+ Logger . Trace ( "Check BranchCache CacheUpdateEvent Current:{0} Check:{1} Result:{2}" , managedCache . LastUpdatedAt ,
267
305
cacheUpdateEvent . UpdatedTimeString ?? "[NULL]" , raiseEvent ) ;
268
306
269
307
if ( raiseEvent )
270
308
{
271
- FireGitLogCacheUpdated ( managedCache . LastUpdatedAt ) ;
309
+ var dateTimeOffset = managedCache . LastUpdatedAt ;
310
+ var updateEvent = new CacheUpdateEvent { UpdatedTimeString = dateTimeOffset . ToString ( ) } ;
311
+ HandleBranchCacheUpdatedEvent ( updateEvent ) ;
272
312
}
273
313
}
274
314
@@ -538,6 +578,16 @@ public List<GitLogEntry> CurrentLog
538
578
set { cacheContainer . GitLogCache . Log = value ; }
539
579
}
540
580
581
+ public event Action < CacheUpdateEvent > LogChanged ;
582
+ public event Action < CacheUpdateEvent > StatusChanged ;
583
+ public event Action < CacheUpdateEvent > CurrentBranchChanged ;
584
+ public event Action < CacheUpdateEvent > CurrentRemoteChanged ;
585
+ public event Action < CacheUpdateEvent > CurrentBranchAndRemoteChanged ;
586
+ public event Action < CacheUpdateEvent > LocalBranchListChanged ;
587
+ public event Action < CacheUpdateEvent > LocksChanged ;
588
+ public event Action < CacheUpdateEvent > RemoteBranchListChanged ;
589
+ public event Action < CacheUpdateEvent > LocalAndRemoteBranchListChanged ;
590
+
541
591
public List < GitLock > CurrentLocks
542
592
{
543
593
get { return cacheContainer . GitLocksCache . GitLocks ; }
0 commit comments