@@ -42,97 +42,6 @@ public Repository(NPath localPath, ICacheContainer container)
4242 cacheContainer . CacheUpdated += CacheContainer_OnCacheUpdated ;
4343 }
4444
45- private void CacheContainer_OnCacheInvalidated ( CacheType cacheType )
46- {
47- switch ( cacheType )
48- {
49- case CacheType . BranchCache :
50- break ;
51-
52- case CacheType . GitLogCache :
53- break ;
54-
55- case CacheType . GitStatusCache :
56- break ;
57-
58- case CacheType . GitLocksCache :
59- break ;
60-
61- case CacheType . GitUserCache :
62- break ;
63-
64- default :
65- throw new ArgumentOutOfRangeException ( nameof ( cacheType ) , cacheType , null ) ;
66- }
67- }
68-
69- private void CacheContainer_OnCacheUpdated ( CacheType cacheType , DateTimeOffset offset )
70- {
71- var cacheUpdateEvent = new CacheUpdateEvent { UpdatedTimeString = offset . ToString ( ) } ;
72- switch ( cacheType )
73- {
74- case CacheType . BranchCache :
75- HandleBranchCacheUpdatedEvent ( cacheUpdateEvent ) ;
76- break ;
77-
78- case CacheType . GitLogCache :
79- HandleGitLogCacheUpdatedEvent ( cacheUpdateEvent ) ;
80- break ;
81-
82- case CacheType . GitStatusCache :
83- HandleGitStatusCacheUpdatedEvent ( cacheUpdateEvent ) ;
84- break ;
85-
86- case CacheType . GitLocksCache :
87- HandleGitLocksCacheUpdatedEvent ( cacheUpdateEvent ) ;
88- break ;
89-
90- case CacheType . GitUserCache :
91- break ;
92-
93- case CacheType . RepositoryInfoCache :
94- HandleRepositoryInfoCacheUpdatedEvent ( cacheUpdateEvent ) ;
95- break ;
96-
97- default :
98- throw new ArgumentOutOfRangeException ( nameof ( cacheType ) , cacheType , null ) ;
99- }
100- }
101-
102- private void HandleRepositoryInfoCacheUpdatedEvent ( CacheUpdateEvent cacheUpdateEvent )
103- {
104- Logger . Trace ( "RepositoryInfoCache Updated {0}" , cacheUpdateEvent . UpdatedTimeString ) ;
105- CurrentBranchChanged ? . Invoke ( cacheUpdateEvent ) ;
106- CurrentRemoteChanged ? . Invoke ( cacheUpdateEvent ) ;
107- CurrentBranchAndRemoteChanged ? . Invoke ( cacheUpdateEvent ) ;
108- }
109-
110- private void HandleGitLocksCacheUpdatedEvent ( CacheUpdateEvent cacheUpdateEvent )
111- {
112- Logger . Trace ( "GitLocksCache Updated {0}" , cacheUpdateEvent . UpdatedTimeString ) ;
113- LocksChanged ? . Invoke ( cacheUpdateEvent ) ;
114- }
115-
116- private void HandleGitStatusCacheUpdatedEvent ( CacheUpdateEvent cacheUpdateEvent )
117- {
118- Logger . Trace ( "GitStatusCache Updated {0}" , cacheUpdateEvent . UpdatedTimeString ) ;
119- StatusChanged ? . Invoke ( cacheUpdateEvent ) ;
120- }
121-
122- private void HandleGitLogCacheUpdatedEvent ( CacheUpdateEvent cacheUpdateEvent )
123- {
124- Logger . Trace ( "GitLogCache Updated {0}" , cacheUpdateEvent . UpdatedTimeString ) ;
125- LogChanged ? . Invoke ( cacheUpdateEvent ) ;
126- }
127-
128- private void HandleBranchCacheUpdatedEvent ( CacheUpdateEvent cacheUpdateEvent )
129- {
130- Logger . Trace ( "BranchCache Updated {0}" , cacheUpdateEvent . UpdatedTimeString ) ;
131- LocalBranchListChanged ? . Invoke ( cacheUpdateEvent ) ;
132- RemoteBranchListChanged ? . Invoke ( cacheUpdateEvent ) ;
133- LocalAndRemoteBranchListChanged ? . Invoke ( cacheUpdateEvent ) ;
134- }
135-
13645 public void Initialize ( IRepositoryManager initRepositoryManager )
13746 {
13847 Logger . Trace ( "Initialize" ) ;
@@ -309,6 +218,38 @@ public void CheckLocalAndRemoteBranchListChangedEvent(CacheUpdateEvent cacheUpda
309218 CheckBranchCacheEvent ( cacheUpdateEvent ) ;
310219 }
311220
221+ /// <summary>
222+ /// Note: We don't consider CloneUrl a part of the hash code because it can change during the lifetime
223+ /// of a repository. Equals takes care of any hash collisions because of this
224+ /// </summary>
225+ /// <returns></returns>
226+ public override int GetHashCode ( )
227+ {
228+ return LocalPath . GetHashCode ( ) ;
229+ }
230+
231+ public override bool Equals ( object obj )
232+ {
233+ if ( ReferenceEquals ( this , obj ) )
234+ return true ;
235+
236+ var other = obj as Repository ;
237+ return Equals ( other ) ;
238+ }
239+
240+ public bool Equals ( Repository other )
241+ {
242+ return Equals ( ( IRepository ) other ) ;
243+ }
244+
245+ public bool Equals ( IRepository other )
246+ {
247+ if ( ReferenceEquals ( this , other ) )
248+ return true ;
249+
250+ return other != null && object . Equals ( LocalPath , other . LocalPath ) ;
251+ }
252+
312253 private void CheckBranchCacheEvent ( CacheUpdateEvent cacheUpdateEvent )
313254 {
314255 var managedCache = cacheContainer . BranchCache ;
@@ -339,36 +280,95 @@ private static bool ShouldRaiseCacheEvent(CacheUpdateEvent cacheUpdateEvent, IMa
339280 return raiseEvent ;
340281 }
341282
342- /// <summary>
343- /// Note: We don't consider CloneUrl a part of the hash code because it can change during the lifetime
344- /// of a repository. Equals takes care of any hash collisions because of this
345- /// </summary>
346- /// <returns></returns>
347- public override int GetHashCode ( )
283+ private void CacheContainer_OnCacheInvalidated ( CacheType cacheType )
348284 {
349- return LocalPath . GetHashCode ( ) ;
285+ switch ( cacheType )
286+ {
287+ case CacheType . BranchCache :
288+ break ;
289+
290+ case CacheType . GitLogCache :
291+ break ;
292+
293+ case CacheType . GitStatusCache :
294+ break ;
295+
296+ case CacheType . GitLocksCache :
297+ break ;
298+
299+ case CacheType . GitUserCache :
300+ break ;
301+
302+ default :
303+ throw new ArgumentOutOfRangeException ( nameof ( cacheType ) , cacheType , null ) ;
304+ }
350305 }
351306
352- public override bool Equals ( object obj )
307+ private void CacheContainer_OnCacheUpdated ( CacheType cacheType , DateTimeOffset offset )
353308 {
354- if ( ReferenceEquals ( this , obj ) )
355- return true ;
309+ var cacheUpdateEvent = new CacheUpdateEvent { UpdatedTimeString = offset . ToString ( ) } ;
310+ switch ( cacheType )
311+ {
312+ case CacheType . BranchCache :
313+ HandleBranchCacheUpdatedEvent ( cacheUpdateEvent ) ;
314+ break ;
356315
357- var other = obj as Repository ;
358- return Equals ( other ) ;
316+ case CacheType . GitLogCache :
317+ HandleGitLogCacheUpdatedEvent ( cacheUpdateEvent ) ;
318+ break ;
319+
320+ case CacheType . GitStatusCache :
321+ HandleGitStatusCacheUpdatedEvent ( cacheUpdateEvent ) ;
322+ break ;
323+
324+ case CacheType . GitLocksCache :
325+ HandleGitLocksCacheUpdatedEvent ( cacheUpdateEvent ) ;
326+ break ;
327+
328+ case CacheType . GitUserCache :
329+ break ;
330+
331+ case CacheType . RepositoryInfoCache :
332+ HandleRepositoryInfoCacheUpdatedEvent ( cacheUpdateEvent ) ;
333+ break ;
334+
335+ default :
336+ throw new ArgumentOutOfRangeException ( nameof ( cacheType ) , cacheType , null ) ;
337+ }
359338 }
360339
361- public bool Equals ( Repository other )
340+ private void HandleRepositoryInfoCacheUpdatedEvent ( CacheUpdateEvent cacheUpdateEvent )
362341 {
363- return Equals ( ( IRepository ) other ) ;
342+ Logger . Trace ( "RepositoryInfoCache Updated {0}" , cacheUpdateEvent . UpdatedTimeString ) ;
343+ CurrentBranchChanged ? . Invoke ( cacheUpdateEvent ) ;
344+ CurrentRemoteChanged ? . Invoke ( cacheUpdateEvent ) ;
345+ CurrentBranchAndRemoteChanged ? . Invoke ( cacheUpdateEvent ) ;
364346 }
365347
366- public bool Equals ( IRepository other )
348+ private void HandleGitLocksCacheUpdatedEvent ( CacheUpdateEvent cacheUpdateEvent )
367349 {
368- if ( ReferenceEquals ( this , other ) )
369- return true ;
350+ Logger . Trace ( "GitLocksCache Updated {0}" , cacheUpdateEvent . UpdatedTimeString ) ;
351+ LocksChanged ? . Invoke ( cacheUpdateEvent ) ;
352+ }
370353
371- return other != null && object . Equals ( LocalPath , other . LocalPath ) ;
354+ private void HandleGitStatusCacheUpdatedEvent ( CacheUpdateEvent cacheUpdateEvent )
355+ {
356+ Logger . Trace ( "GitStatusCache Updated {0}" , cacheUpdateEvent . UpdatedTimeString ) ;
357+ StatusChanged ? . Invoke ( cacheUpdateEvent ) ;
358+ }
359+
360+ private void HandleGitLogCacheUpdatedEvent ( CacheUpdateEvent cacheUpdateEvent )
361+ {
362+ Logger . Trace ( "GitLogCache Updated {0}" , cacheUpdateEvent . UpdatedTimeString ) ;
363+ LogChanged ? . Invoke ( cacheUpdateEvent ) ;
364+ }
365+
366+ private void HandleBranchCacheUpdatedEvent ( CacheUpdateEvent cacheUpdateEvent )
367+ {
368+ Logger . Trace ( "BranchCache Updated {0}" , cacheUpdateEvent . UpdatedTimeString ) ;
369+ LocalBranchListChanged ? . Invoke ( cacheUpdateEvent ) ;
370+ RemoteBranchListChanged ? . Invoke ( cacheUpdateEvent ) ;
371+ LocalAndRemoteBranchListChanged ? . Invoke ( cacheUpdateEvent ) ;
372372 }
373373
374374 private void RepositoryManager_OnCurrentRemoteUpdated ( ConfigRemote ? remote )
0 commit comments