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

Commit 9643fb8

Browse files
Serialize the name and email directly
More rippling changes from the previous implementation attempt
1 parent 60312fd commit 9643fb8

File tree

3 files changed

+40
-17
lines changed

3 files changed

+40
-17
lines changed

src/GitHub.Api/Cache/CacheInterfaces.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ public interface IGitLocksCache : IManagedCache
4949

5050
public interface IGitUserCache : IManagedCache
5151
{
52-
User User { get; set; }
52+
string Name { get; set; }
53+
string Email { get; set; }
5354
}
5455

5556
public interface IGitStatusCache : IManagedCache

src/GitHub.Api/Git/Repository.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -713,14 +713,14 @@ public override string ToString()
713713

714714
public string Name
715715
{
716-
get { return cacheContainer.GitUserCache.User.Name; }
717-
private set { cacheContainer.GitUserCache.User.Name = value; }
716+
get { return cacheContainer.GitUserCache.Name; }
717+
private set { cacheContainer.GitUserCache.Name = value; }
718718
}
719719

720720
public string Email
721721
{
722-
get { return cacheContainer.GitUserCache.User.Email; }
723-
private set { cacheContainer.GitUserCache.User.Email = value; }
722+
get { return cacheContainer.GitUserCache.Email; }
723+
private set { cacheContainer.GitUserCache.Email = value; }
724724
}
725725

726726
private void GitUserCacheOnCacheUpdated(DateTimeOffset timeOffset)
@@ -747,15 +747,12 @@ private void UpdateUserAndEmail()
747747
{
748748
Logger.Trace("UpdateUserAndEmail");
749749

750-
string username = null;
751-
string email = null;
752-
753750
gitClient.GetConfigUserAndEmail()
754-
.Then((success, value) => {
751+
.ThenInUI((success, value) => {
755752
if (success)
756753
{
757-
username = value.Name;
758-
email = value.Email;
754+
Name = value.Name;
755+
Email = value.Email;
759756
}
760757
}).Start();
761758
}

src/UnityExtension/Assets/Editor/GitHub.Unity/ApplicationCache.cs

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,28 +1008,53 @@ sealed class GitUserCache : ManagedCacheBase<GitUserCache>, IGitUserCache
10081008
[SerializeField] private string lastUpdatedAtString = DateTimeOffset.MinValue.ToString();
10091009
[SerializeField] private string lastVerifiedAtString = DateTimeOffset.MinValue.ToString();
10101010
[SerializeField] private string initializedAtString = DateTimeOffset.MinValue.ToString();
1011-
[SerializeField] private User user;
1011+
[SerializeField] private string gitName;
1012+
[SerializeField] private string gitEmail;
10121013

10131014
public GitUserCache() : base(true)
10141015
{ }
10151016

1016-
public User User
1017+
public string Name
10171018
{
10181019
get
10191020
{
10201021
ValidateData();
1021-
return user;
1022+
return gitName;
10221023
}
10231024
set
10241025
{
10251026
var now = DateTimeOffset.Now;
10261027
var isUpdated = false;
10271028

1028-
Logger.Trace("Updating: {0} user:{1}", now, value);
1029+
Logger.Trace("Updating: {0} Name:{1}", now, value);
10291030

1030-
if (!user.Equals(value))
1031+
if (!gitName.Equals(value))
10311032
{
1032-
user = value;
1033+
gitName = value;
1034+
isUpdated = true;
1035+
}
1036+
1037+
SaveData(now, isUpdated);
1038+
}
1039+
}
1040+
1041+
public string Email
1042+
{
1043+
get
1044+
{
1045+
ValidateData();
1046+
return gitEmail;
1047+
}
1048+
set
1049+
{
1050+
var now = DateTimeOffset.Now;
1051+
var isUpdated = false;
1052+
1053+
Logger.Trace("Updating: {0} Email:{1}", now, value);
1054+
1055+
if (!gitEmail.Equals(value))
1056+
{
1057+
gitEmail = value;
10331058
isUpdated = true;
10341059
}
10351060

0 commit comments

Comments
 (0)