Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions src/GitHub.Api/Git/GitClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ITask<string> GetConfig(string key, GitConfigSource configSource,
ITask<string> SetConfig(string key, string value, GitConfigSource configSource,
IOutputProcessor<string> processor = null);

ITask<string[]> GetConfigUserAndEmail();
ITask<User> GetConfigUserAndEmail();

ITask<List<GitLock>> ListLocks(bool local,
BaseOutputListProcessor<GitLock> processor = null);
Expand Down Expand Up @@ -255,26 +255,28 @@ public ITask<string> SetConfig(string key, string value, GitConfigSource configS
.Configure(processManager);
}

public ITask<string[]> GetConfigUserAndEmail()
public ITask<User> GetConfigUserAndEmail()
{
string username = null;
string email = null;

return GetConfig("user.name", GitConfigSource.User).Then((success, value) => {
if (success)
{
username = value;
}

}).Then(GetConfig("user.email", GitConfigSource.User).Then((success, value) => {
if (success)
{
email = value;
}
})).Then(success => {
Logger.Trace("user.name:{1} user.email:{2}", success, username, email);
return new[] { username, email };
});
return GetConfig("user.name", GitConfigSource.User)
.Then((success, value) => {
if (success)
{
username = value;
}
})
.Then(GetConfig("user.email", GitConfigSource.User)
.Then((success, value) => {
if (success)
{
email = value;
}
})).Then(success => {
Logger.Trace("{0}:{1} {2}:{3}", "user.name", username, "user.email", email);
return new User { Name= username, Email = email };
});
}

public ITask<List<GitLock>> ListLocks(bool local, BaseOutputListProcessor<GitLock> processor = null)
Expand Down
11 changes: 1 addition & 10 deletions src/GitHub.Api/Git/RepositoryManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -299,18 +299,9 @@ public ITask UnlockFile(string file, bool force)
private void LoadGitUser()
{
GitClient.GetConfigUserAndEmail()
.Then((success, strings) => {
var username = strings[0];
var email = strings[1];

var user = new User {
Name = username,
Email = email
};

.Then((success, user) => {
Logger.Trace("OnGitUserLoaded: {0}", user);
OnGitUserLoaded?.Invoke(user);

}).Start();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,9 @@ private void CheckForUser()
Logger.Trace("Checking for user");
isBusy = true;

GitClient.GetConfigUserAndEmail().FinallyInUI((success, ex, strings) => {
var username = strings[0];
var email = strings[1];

GitClient.GetConfigUserAndEmail().FinallyInUI((success, ex, user) => {
isBusy = false;
isUserDataPresent = success && !String.IsNullOrEmpty(username) && !String.IsNullOrEmpty(email);
isUserDataPresent = success && !String.IsNullOrEmpty(user.Name) && !String.IsNullOrEmpty(user.Email);
hasCompletedInitialCheck = true;

Logger.Trace("User Present: {0}", isUserDataPresent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,10 @@ private void MaybeUpdateData()
{
if ((cachedUser == null || String.IsNullOrEmpty(cachedUser.Name)) && GitClient != null)
{
GitClient.GetConfigUserAndEmail().FinallyInUI((success, ex, strings) => {
var username = strings[0];
var email = strings[1];

if (success && !String.IsNullOrEmpty(username) && !String.IsNullOrEmpty(email))
GitClient.GetConfigUserAndEmail().FinallyInUI((success, ex, user) => {
if (success && !String.IsNullOrEmpty(user.Name) && !String.IsNullOrEmpty(user.Email))
{
cachedUser = new User {
Name = username,
Email = email
};
cachedUser = user;

userDataHasChanged = true;
Redraw();
Expand Down