@@ -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,116 @@ 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 ;
208
- var raiseEvent = ShouldRaiseCacheEvent ( cacheUpdateEvent , managedCache ) ;
206
+ CacheUpdateEvent cacheUpdateEvent1 = cacheUpdateEvent ;
207
+ var managedCache = cacheContainer . GitLogCache ;
208
+ var raiseEvent = ShouldRaiseCacheEvent ( cacheUpdateEvent1 , managedCache ) ;
209
209
210
- Logger . Trace ( "CheckRepositoryInfoCacheEvent Current:{0} Check:{1} Result:{2}" , managedCache . LastUpdatedAt ,
211
- cacheUpdateEvent . UpdatedTimeString ?? "[NULL]" , raiseEvent ) ;
210
+ Logger . Trace ( "CheckGitLogCacheEvent Current:{0} Check:{1} Result:{2}" , managedCache . LastUpdatedAt ,
211
+ cacheUpdateEvent1 . UpdatedTimeString ?? "[NULL]" , raiseEvent ) ;
212
212
213
213
if ( raiseEvent )
214
214
{
215
- FireBranchCacheUpdated ( managedCache . LastUpdatedAt ) ;
215
+ var dateTimeOffset = managedCache . LastUpdatedAt ;
216
+ var updateEvent = new CacheUpdateEvent { UpdatedTimeString = dateTimeOffset . ToString ( ) } ;
217
+ HandleGitLogCacheUpdatedEvent ( updateEvent ) ;
216
218
}
217
219
}
218
220
219
- public void CheckBranchCacheEvent ( CacheUpdateEvent cacheUpdateEvent )
221
+ public void CheckStatusChangedEvent ( CacheUpdateEvent cacheUpdateEvent )
220
222
{
221
- var managedCache = cacheContainer . BranchCache ;
222
- var raiseEvent = ShouldRaiseCacheEvent ( cacheUpdateEvent , managedCache ) ;
223
+ CacheUpdateEvent cacheUpdateEvent1 = cacheUpdateEvent ;
224
+ var managedCache = cacheContainer . GitStatusCache ;
225
+ var raiseEvent = ShouldRaiseCacheEvent ( cacheUpdateEvent1 , managedCache ) ;
223
226
224
- Logger . Trace ( "CheckBranchCacheEvent Current:{0} Check:{1} Result:{2}" , managedCache . LastUpdatedAt ,
225
- cacheUpdateEvent . UpdatedTimeString ?? "[NULL]" , raiseEvent ) ;
227
+ Logger . Trace ( "CheckGitStatusCacheEvent Current:{0} Check:{1} Result:{2}" , managedCache . LastUpdatedAt ,
228
+ cacheUpdateEvent1 . UpdatedTimeString ?? "[NULL]" , raiseEvent ) ;
226
229
227
230
if ( raiseEvent )
228
231
{
229
- FireBranchCacheUpdated ( managedCache . LastUpdatedAt ) ;
232
+ var dateTimeOffset = managedCache . LastUpdatedAt ;
233
+ var updateEvent = new CacheUpdateEvent { UpdatedTimeString = dateTimeOffset . ToString ( ) } ;
234
+ HandleGitStatucCacheUpdatedEvent ( updateEvent ) ;
230
235
}
231
236
}
232
237
233
- public void CheckGitStatusCacheEvent ( CacheUpdateEvent cacheUpdateEvent )
238
+ public void CheckCurrentBranchChangedEvent ( CacheUpdateEvent cacheUpdateEvent )
234
239
{
235
- var managedCache = cacheContainer . GitStatusCache ;
240
+ CheckRepositoryInfoCacheEvent ( cacheUpdateEvent ) ;
241
+ }
242
+
243
+ public void CheckCurrentRemoteChangedEvent ( CacheUpdateEvent cacheUpdateEvent )
244
+ {
245
+ CheckRepositoryInfoCacheEvent ( cacheUpdateEvent ) ;
246
+ }
247
+
248
+ public void CheckCurrentBranchAndRemoteChangedEvent ( CacheUpdateEvent cacheUpdateEvent )
249
+ {
250
+ CheckRepositoryInfoCacheEvent ( cacheUpdateEvent ) ;
251
+ }
252
+
253
+ private void CheckRepositoryInfoCacheEvent ( CacheUpdateEvent cacheUpdateEvent )
254
+ {
255
+ var managedCache = cacheContainer . RepositoryInfoCache ;
236
256
var raiseEvent = ShouldRaiseCacheEvent ( cacheUpdateEvent , managedCache ) ;
237
257
238
- Logger . Trace ( "CheckGitStatusCacheEvent Current:{0} Check:{1} Result:{2}" , managedCache . LastUpdatedAt ,
258
+ Logger . Trace ( "CheckRepositoryInfoCacheEvent Current:{0} Check:{1} Result:{2}" , managedCache . LastUpdatedAt ,
239
259
cacheUpdateEvent . UpdatedTimeString ?? "[NULL]" , raiseEvent ) ;
240
260
241
261
if ( raiseEvent )
242
262
{
243
- FireGitStatusCacheUpdated ( managedCache . LastUpdatedAt ) ;
263
+ var dateTimeOffset = managedCache . LastUpdatedAt ;
264
+ var updateEvent = new CacheUpdateEvent { UpdatedTimeString = dateTimeOffset . ToString ( ) } ;
265
+ HandleRepositoryInfoCacheUpdatedEvent ( updateEvent ) ;
244
266
}
245
267
}
246
268
247
- public void CheckGitLogCacheEvent ( CacheUpdateEvent cacheUpdateEvent )
269
+ public void CheckLocksChangedEvent ( CacheUpdateEvent cacheUpdateEvent )
248
270
{
249
- var managedCache = cacheContainer . GitLogCache ;
250
- var raiseEvent = ShouldRaiseCacheEvent ( cacheUpdateEvent , managedCache ) ;
271
+ CacheUpdateEvent cacheUpdateEvent1 = cacheUpdateEvent ;
272
+ var managedCache = cacheContainer . GitLocksCache ;
273
+ var raiseEvent = ShouldRaiseCacheEvent ( cacheUpdateEvent1 , managedCache ) ;
251
274
252
- Logger . Trace ( "CheckGitLogCacheEvent Current:{0} Check:{1} Result:{2}" , managedCache . LastUpdatedAt ,
253
- cacheUpdateEvent . UpdatedTimeString ?? "[NULL]" , raiseEvent ) ;
275
+ Logger . Trace ( "CheckGitLocksCacheEvent Current:{0} Check:{1} Result:{2}" , managedCache . LastUpdatedAt ,
276
+ cacheUpdateEvent1 . UpdatedTimeString ?? "[NULL]" , raiseEvent ) ;
254
277
255
278
if ( raiseEvent )
256
279
{
257
- FireGitLogCacheUpdated ( managedCache . LastUpdatedAt ) ;
280
+ var dateTimeOffset = managedCache . LastUpdatedAt ;
281
+ var updateEvent = new CacheUpdateEvent { UpdatedTimeString = dateTimeOffset . ToString ( ) } ;
282
+ HandleGitLocksCacheUpdatedEvent ( updateEvent ) ;
258
283
}
259
284
}
260
285
261
- public void CheckGitLocksCacheEvent ( CacheUpdateEvent cacheUpdateEvent )
286
+ public void CheckLocalBranchListChangedEvent ( CacheUpdateEvent cacheUpdateEvent )
262
287
{
263
- var managedCache = cacheContainer . GitLocksCache ;
288
+ CheckBranchCacheEvent ( cacheUpdateEvent ) ;
289
+ }
290
+
291
+ public void CheckRemoteBranchListChangedEvent ( CacheUpdateEvent cacheUpdateEvent )
292
+ {
293
+ CheckBranchCacheEvent ( cacheUpdateEvent ) ;
294
+ }
295
+
296
+ public void CheckLocalAndRemoteBranchListChangedEvent ( CacheUpdateEvent cacheUpdateEvent )
297
+ {
298
+ CheckBranchCacheEvent ( cacheUpdateEvent ) ;
299
+ }
300
+
301
+ private void CheckBranchCacheEvent ( CacheUpdateEvent cacheUpdateEvent )
302
+ {
303
+ var managedCache = cacheContainer . BranchCache ;
264
304
var raiseEvent = ShouldRaiseCacheEvent ( cacheUpdateEvent , managedCache ) ;
265
305
266
- Logger . Trace ( "CheckGitLocksCacheEvent Current:{0} Check:{1} Result:{2}" , managedCache . LastUpdatedAt ,
306
+ Logger . Trace ( "CheckBranchCacheEvent Current:{0} Check:{1} Result:{2}" , managedCache . LastUpdatedAt ,
267
307
cacheUpdateEvent . UpdatedTimeString ?? "[NULL]" , raiseEvent ) ;
268
308
269
309
if ( raiseEvent )
270
310
{
271
- FireGitLogCacheUpdated ( managedCache . LastUpdatedAt ) ;
311
+ var dateTimeOffset = managedCache . LastUpdatedAt ;
312
+ var updateEvent = new CacheUpdateEvent { UpdatedTimeString = dateTimeOffset . ToString ( ) } ;
313
+ HandleBranchCacheUpdatedEvent ( updateEvent ) ;
272
314
}
273
315
}
274
316
@@ -523,6 +565,16 @@ public List<GitLogEntry> CurrentLog
523
565
set { cacheContainer . GitLogCache . Log = value ; }
524
566
}
525
567
568
+ public event Action < CacheUpdateEvent > LogChanged ;
569
+ public event Action < CacheUpdateEvent > StatusChanged ;
570
+ public event Action < CacheUpdateEvent > CurrentBranchChanged ;
571
+ public event Action < CacheUpdateEvent > CurrentRemoteChanged ;
572
+ public event Action < CacheUpdateEvent > CurrentBranchAndRemoteChanged ;
573
+ public event Action < CacheUpdateEvent > LocalBranchListChanged ;
574
+ public event Action < CacheUpdateEvent > LocksChanged ;
575
+ public event Action < CacheUpdateEvent > RemoteBranchListChanged ;
576
+ public event Action < CacheUpdateEvent > LocalAndRemoteBranchListChanged ;
577
+
526
578
public List < GitLock > CurrentLocks
527
579
{
528
580
get { return cacheContainer . GitLocksCache . GitLocks ; }
0 commit comments