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

Commit 9f817bf

Browse files
Adding SetConfigUserAndEmail to GitClient and using it in UserSettingsView
1 parent 0515a92 commit 9f817bf

File tree

2 files changed

+24
-34
lines changed

2 files changed

+24
-34
lines changed

src/GitHub.Api/Git/GitClient.cs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ ITask<string> Unlock(string file, bool force,
8383
ITask<Version> Version(IOutputProcessor<Version> processor = null);
8484

8585
ITask<Version> LfsVersion(IOutputProcessor<Version> processor = null);
86+
87+
ITask<User> SetConfigUserAndEmail(string username, string email);
8688
}
8789

8890
class GitClient : IGitClient
@@ -270,17 +272,24 @@ public ITask<User> GetConfigUserAndEmail()
270272
}
271273
})
272274
.Then(GetConfig(UserEmailConfigKey, GitConfigSource.User)
273-
.Then((success, value) => {
274-
if (success)
275-
{
276-
email = value;
277-
}
278-
})).Then(success => {
275+
.Then((success, value) => {
276+
if (success)
277+
{
278+
email = value;
279+
}
280+
})).Then(success => {
279281
Logger.Trace("{0}:{1} {2}:{3}", UserNameConfigKey, username, UserEmailConfigKey, email);
280-
return new User { Name= username, Email = email };
282+
return new User { Name = username, Email = email };
281283
});
282284
}
283285

286+
public ITask<User> SetConfigUserAndEmail(string username, string email)
287+
{
288+
return SetConfig(UserNameConfigKey, username, GitConfigSource.User)
289+
.Then(SetConfig(UserEmailConfigKey, email, GitConfigSource.User))
290+
.Then(b => new User { Name = username, Email = email });
291+
}
292+
284293
public ITask<List<GitLock>> ListLocks(bool local, BaseOutputListProcessor<GitLock> processor = null)
285294
{
286295
Logger.Trace("ListLocks");

src/UnityExtension/Assets/Editor/GitHub.Unity/UI/UserSettingsView.cs

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,15 @@ public override void OnGUI()
5656
GUI.FocusControl(null);
5757
isBusy = true;
5858

59-
GitClient.SetConfig("user.name", newGitName, GitConfigSource.User)
60-
.Then((success, value) =>
61-
{
59+
GitClient.SetConfigUserAndEmail(newGitName, newGitEmail)
60+
.FinallyInUI((success, exception, user) => {
61+
isBusy = false;
6262
if (success)
6363
{
6464
if (Repository != null)
6565
{
6666
Repository.User.Name = newGitName;
67+
Repository.User.Email = newGitEmail;
6768
}
6869
else
6970
{
@@ -72,33 +73,13 @@ public override void OnGUI()
7273
cachedUser = new User();
7374
}
7475
cachedUser.Name = newGitName;
76+
cachedUser.Email = newGitEmail;
7577
}
78+
79+
Redraw();
80+
Finish(true);
7681
}
7782
})
78-
.Then(
79-
GitClient.SetConfig("user.email", newGitEmail, GitConfigSource.User)
80-
.Then((success, value) =>
81-
{
82-
if (success)
83-
{
84-
if (Repository != null)
85-
{
86-
Repository.User.Email = newGitEmail;
87-
}
88-
else
89-
{
90-
cachedUser.Email = newGitEmail;
91-
}
92-
93-
userDataHasChanged = true;
94-
}
95-
}))
96-
.FinallyInUI((_, __) =>
97-
{
98-
isBusy = false;
99-
Redraw();
100-
Finish(true);
101-
})
10283
.Start();
10384
}
10485
}

0 commit comments

Comments
 (0)