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

Commit 7ac73ec

Browse files
Moving functionality to set name and email
Moving the functionality to set the name an email to User and changing UserSettingsView to use that method. Also did some minor method renames.
1 parent e54fef8 commit 7ac73ec

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

src/GitHub.Api/Application/ApplicationManagerBase.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ private async Task SetupGit()
7878
}
7979
}
8080

81+
Environment.User.Initialize(GitClient);
8182
}
8283

8384
public ITask InitializeRepository()

src/GitHub.Api/Git/GitClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ ITask<string> Unlock(string file, bool force,
8484

8585
ITask<Version> LfsVersion(IOutputProcessor<Version> processor = null);
8686

87-
ITask<GitUser> SetConfigUserAndEmail(string username, string email);
87+
ITask<GitUser> SetConfigNameAndEmail(string username, string email);
8888
}
8989

9090
class GitClient : IGitClient
@@ -283,7 +283,7 @@ public ITask<GitUser> GetConfigUserAndEmail()
283283
});
284284
}
285285

286-
public ITask<GitUser> SetConfigUserAndEmail(string username, string email)
286+
public ITask<GitUser> SetConfigNameAndEmail(string username, string email)
287287
{
288288
return SetConfig(UserNameConfigKey, username, GitConfigSource.User)
289289
.Then(SetConfig(UserEmailConfigKey, email, GitConfigSource.User))

src/GitHub.Api/Git/Repository.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,8 @@ public interface IUser
672672
string Email { get; }
673673
event Action<CacheUpdateEvent> UserChanged;
674674
void CheckUserChangedEvent(CacheUpdateEvent cacheUpdateEvent);
675+
void Initialize(IGitClient client);
676+
void SetNameAndEmail(string name, string email);
675677
}
676678

677679
[Serializable]
@@ -706,6 +708,28 @@ public void CheckUserChangedEvent(CacheUpdateEvent cacheUpdateEvent)
706708
}
707709
}
708710

711+
public void Initialize(IGitClient client)
712+
{
713+
Guard.ArgumentNotNull(client, nameof(client));
714+
715+
Logger.Trace("Initialize");
716+
717+
gitClient = client;
718+
UpdateUserAndEmail();
719+
}
720+
721+
public void SetNameAndEmail(string name, string email)
722+
{
723+
gitClient.SetConfigNameAndEmail(name, email)
724+
.ThenInUI((success, value) => {
725+
if (success)
726+
{
727+
Name = value.Name;
728+
Email = value.Email;
729+
}
730+
}).Start();
731+
}
732+
709733
public override string ToString()
710734
{
711735
return String.Format("Name: {0} Email: {1}", Name, Email);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public override void OnGUI()
6363
GUI.FocusControl(null);
6464
isBusy = true;
6565

66-
GitClient.SetConfigUserAndEmail(newGitName, newGitEmail);
66+
User.SetNameAndEmail(newGitName, newGitEmail);
6767
}
6868
}
6969
EditorGUI.EndDisabledGroup();
@@ -92,7 +92,7 @@ private void AttachHandlers()
9292

9393
private void UserOnUserChanged(CacheUpdateEvent cacheUpdateEvent)
9494
{
95-
Logger.Trace("GitClientOnCurrentUserChanged");
95+
Logger.Trace("UserOnUserChanged");
9696

9797
if (!lastCheckUserChangedEvent.Equals(cacheUpdateEvent))
9898
{

0 commit comments

Comments
 (0)