@@ -101,7 +101,7 @@ class GitClient : IGitClient
101
101
private readonly CancellationToken cancellationToken ;
102
102
103
103
public event Action < CacheUpdateEvent > CurrentUserChanged ;
104
- private bool cacheInitialized = false ;
104
+ private bool cacheInitialized ;
105
105
106
106
public GitClient ( IEnvironment environment , IProcessManager processManager , ITaskManager taskManager )
107
107
{
@@ -113,20 +113,6 @@ public GitClient(IEnvironment environment, IProcessManager processManager, ITask
113
113
this . cancellationToken = taskManager . Token ;
114
114
}
115
115
116
- private void GitUserCacheOnCacheUpdated ( DateTimeOffset timeOffset )
117
- {
118
- HandleGitLogCacheUpdatedEvent ( new CacheUpdateEvent
119
- {
120
- UpdatedTimeString = timeOffset . ToString ( )
121
- } ) ;
122
- }
123
-
124
- private void GitUserCacheOnCacheInvalidated ( )
125
- {
126
- Logger . Trace ( "GitUserCache Invalidated" ) ;
127
- UpdateUserAndEmail ( ) ;
128
- }
129
-
130
116
public void CheckUserChangedEvent ( CacheUpdateEvent cacheUpdateEvent )
131
117
{
132
118
var managedCache = environment . CacheContainer . GitUserCache ;
@@ -142,11 +128,6 @@ public void CheckUserChangedEvent(CacheUpdateEvent cacheUpdateEvent)
142
128
HandleGitLogCacheUpdatedEvent ( updateEvent ) ;
143
129
}
144
130
}
145
- private void HandleGitLogCacheUpdatedEvent ( CacheUpdateEvent cacheUpdateEvent )
146
- {
147
- Logger . Trace ( "GitUserCache Updated {0}" , cacheUpdateEvent . UpdatedTimeString ) ;
148
- CurrentUserChanged ? . Invoke ( cacheUpdateEvent ) ;
149
- }
150
131
151
132
public User CurrentUser
152
133
{
@@ -319,34 +300,6 @@ public ITask<string> SetConfig(string key, string value, GitConfigSource configS
319
300
. Configure ( processManager ) ;
320
301
}
321
302
322
- private void UpdateUserAndEmail ( )
323
- {
324
- Logger . Trace ( "UpdateUserAndEmail" ) ;
325
-
326
- string username = null ;
327
- string email = null ;
328
-
329
- GetConfig ( UserNameConfigKey , GitConfigSource . User )
330
- . Then ( ( success , value ) => {
331
- if ( success )
332
- {
333
- username = value ;
334
- }
335
- } )
336
- . Then ( GetConfig ( UserEmailConfigKey , GitConfigSource . User )
337
- . Then ( ( success , value ) => {
338
- if ( success )
339
- {
340
- email = value ;
341
- }
342
- } ) ) . ThenInUI ( success => {
343
- environment . CacheContainer . GitUserCache . User = new User {
344
- Name = username ,
345
- Email = email
346
- } ;
347
- } ) . Start ( ) ;
348
- }
349
-
350
303
public void SetConfigUserAndEmail ( string username , string email )
351
304
{
352
305
SetConfig ( UserNameConfigKey , username , GitConfigSource . User )
@@ -527,6 +480,54 @@ public ITask<string> Unlock(string file, bool force,
527
480
. Configure ( processManager ) ;
528
481
}
529
482
483
+ private void GitUserCacheOnCacheUpdated ( DateTimeOffset timeOffset )
484
+ {
485
+ HandleGitLogCacheUpdatedEvent ( new CacheUpdateEvent
486
+ {
487
+ UpdatedTimeString = timeOffset . ToString ( )
488
+ } ) ;
489
+ }
490
+
491
+ private void GitUserCacheOnCacheInvalidated ( )
492
+ {
493
+ Logger . Trace ( "GitUserCache Invalidated" ) ;
494
+ UpdateUserAndEmail ( ) ;
495
+ }
496
+
497
+ private void HandleGitLogCacheUpdatedEvent ( CacheUpdateEvent cacheUpdateEvent )
498
+ {
499
+ Logger . Trace ( "GitUserCache Updated {0}" , cacheUpdateEvent . UpdatedTimeString ) ;
500
+ CurrentUserChanged ? . Invoke ( cacheUpdateEvent ) ;
501
+ }
502
+
503
+ private void UpdateUserAndEmail ( )
504
+ {
505
+ Logger . Trace ( "UpdateUserAndEmail" ) ;
506
+
507
+ string username = null ;
508
+ string email = null ;
509
+
510
+ GetConfig ( UserNameConfigKey , GitConfigSource . User )
511
+ . Then ( ( success , value ) => {
512
+ if ( success )
513
+ {
514
+ username = value ;
515
+ }
516
+ } )
517
+ . Then ( GetConfig ( UserEmailConfigKey , GitConfigSource . User )
518
+ . Then ( ( success , value ) => {
519
+ if ( success )
520
+ {
521
+ email = value ;
522
+ }
523
+ } ) ) . ThenInUI ( success => {
524
+ CurrentUser = new User {
525
+ Name = username ,
526
+ Email = email
527
+ } ;
528
+ } ) . Start ( ) ;
529
+ }
530
+
530
531
protected static ILogging Logger { get ; } = Logging . GetLogger < GitClient > ( ) ;
531
532
}
532
533
}
0 commit comments