Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 46c8dde

Browse files
Reordering functions
1 parent d4f5576 commit 46c8dde

File tree

1 file changed

+49
-48
lines changed

1 file changed

+49
-48
lines changed

src/GitHub.Api/Git/GitClient.cs

Lines changed: 49 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class GitClient : IGitClient
101101
private readonly CancellationToken cancellationToken;
102102

103103
public event Action<CacheUpdateEvent> CurrentUserChanged;
104-
private bool cacheInitialized = false;
104+
private bool cacheInitialized;
105105

106106
public GitClient(IEnvironment environment, IProcessManager processManager, ITaskManager taskManager)
107107
{
@@ -113,20 +113,6 @@ public GitClient(IEnvironment environment, IProcessManager processManager, ITask
113113
this.cancellationToken = taskManager.Token;
114114
}
115115

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-
130116
public void CheckUserChangedEvent(CacheUpdateEvent cacheUpdateEvent)
131117
{
132118
var managedCache = environment.CacheContainer.GitUserCache;
@@ -142,11 +128,6 @@ public void CheckUserChangedEvent(CacheUpdateEvent cacheUpdateEvent)
142128
HandleGitLogCacheUpdatedEvent(updateEvent);
143129
}
144130
}
145-
private void HandleGitLogCacheUpdatedEvent(CacheUpdateEvent cacheUpdateEvent)
146-
{
147-
Logger.Trace("GitUserCache Updated {0}", cacheUpdateEvent.UpdatedTimeString);
148-
CurrentUserChanged?.Invoke(cacheUpdateEvent);
149-
}
150131

151132
public User CurrentUser
152133
{
@@ -319,34 +300,6 @@ public ITask<string> SetConfig(string key, string value, GitConfigSource configS
319300
.Configure(processManager);
320301
}
321302

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-
350303
public void SetConfigUserAndEmail(string username, string email)
351304
{
352305
SetConfig(UserNameConfigKey, username, GitConfigSource.User)
@@ -527,6 +480,54 @@ public ITask<string> Unlock(string file, bool force,
527480
.Configure(processManager);
528481
}
529482

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+
530531
protected static ILogging Logger { get; } = Logging.GetLogger<GitClient>();
531532
}
532533
}

0 commit comments

Comments
 (0)