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

Commit 2256998

Browse files
Merge branch 'master' into fixes/repository-manager-tests
2 parents 0f51485 + 64e45bd commit 2256998

File tree

10 files changed

+102
-78
lines changed

10 files changed

+102
-78
lines changed

common/SolutionInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@
3131
namespace System
3232
{
3333
internal static class AssemblyVersionInformation {
34-
internal const string Version = "0.22.0";
34+
internal const string Version = "0.23.0";
3535
}
3636
}

src/GitHub.Api/Git/GitClient.cs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ ITask<string> GetConfig(string key, GitConfigSource configSource,
2323
ITask<string> SetConfig(string key, string value, GitConfigSource configSource,
2424
IOutputProcessor<string> processor = null);
2525

26-
ITask<string[]> GetConfigUserAndEmail();
26+
ITask<User> GetConfigUserAndEmail();
2727

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

258-
public ITask<string[]> GetConfigUserAndEmail()
258+
public ITask<User> GetConfigUserAndEmail()
259259
{
260260
string username = null;
261261
string email = null;
262262

263-
return GetConfig("user.name", GitConfigSource.User).Then((success, value) => {
264-
if (success)
265-
{
266-
username = value;
267-
}
268-
269-
}).Then(GetConfig("user.email", GitConfigSource.User).Then((success, value) => {
270-
if (success)
271-
{
272-
email = value;
273-
}
274-
})).Then(success => {
275-
Logger.Trace("user.name:{1} user.email:{2}", success, username, email);
276-
return new[] { username, email };
277-
});
263+
return GetConfig("user.name", GitConfigSource.User)
264+
.Then((success, value) => {
265+
if (success)
266+
{
267+
username = value;
268+
}
269+
})
270+
.Then(GetConfig("user.email", GitConfigSource.User)
271+
.Then((success, value) => {
272+
if (success)
273+
{
274+
email = value;
275+
}
276+
})).Then(success => {
277+
Logger.Trace("{0}:{1} {2}:{3}", "user.name", username, "user.email", email);
278+
return new User { Name= username, Email = email };
279+
});
278280
}
279281

280282
public ITask<List<GitLock>> ListLocks(bool local, BaseOutputListProcessor<GitLock> processor = null)

src/GitHub.Api/Git/IRepository.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ public interface IRepository : IEquatable<IRepository>
1919
ITask RequestLock(string file);
2020
ITask ReleaseLock(string file, bool force);
2121

22+
void RefreshLog();
23+
void RefreshStatus();
24+
void UpdateConfigData();
2225
void CheckLogChangedEvent(CacheUpdateEvent gitLogCacheUpdateEvent);
2326
void CheckStatusChangedEvent(CacheUpdateEvent cacheUpdateEvent);
2427
void CheckCurrentBranchChangedEvent(CacheUpdateEvent cacheUpdateEvent);

src/GitHub.Api/Git/Repository.cs

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,22 @@ public ITask SetupRemote(string remote, string remoteUrl)
8181

8282
public ITask CommitAllFiles(string message, string body)
8383
{
84-
return repositoryManager.CommitAllFiles(message, body);
84+
return repositoryManager
85+
.CommitAllFiles(message, body)
86+
.Then(() => {
87+
UpdateGitStatus();
88+
UpdateGitLog();
89+
});
8590
}
8691

8792
public ITask CommitFiles(List<string> files, string message, string body)
8893
{
89-
return repositoryManager.CommitFiles(files, message, body);
94+
return repositoryManager
95+
.CommitFiles(files, message, body)
96+
.Then(() => {
97+
UpdateGitStatus();
98+
UpdateGitLog();
99+
});
90100
}
91101

92102
public ITask Pull()
@@ -122,6 +132,21 @@ public ITask ReleaseLock(string file, bool force)
122132
.Then(UpdateLocks);
123133
}
124134

135+
public void RefreshLog()
136+
{
137+
UpdateGitLog();
138+
}
139+
140+
public void RefreshStatus()
141+
{
142+
UpdateGitStatus();
143+
}
144+
145+
public void UpdateConfigData()
146+
{
147+
repositoryManager?.UpdateConfigData();
148+
}
149+
125150
public void CheckLogChangedEvent(CacheUpdateEvent cacheUpdateEvent)
126151
{
127152
var managedCache = cacheContainer.GitLogCache;

src/GitHub.Api/Git/RepositoryManager.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public interface IRepositoryManager : IDisposable
4040
ITask LockFile(string file);
4141
ITask UnlockFile(string file, bool force);
4242
int WaitForEvents();
43+
void UpdateConfigData();
4344

4445
IGitConfig Config { get; }
4546
IGitClient GitClient { get; }
@@ -296,21 +297,17 @@ public ITask UnlockFile(string file, bool force)
296297
return HookupHandlers(task);
297298
}
298299

300+
public void UpdateConfigData()
301+
{
302+
UpdateConfigData(false);
303+
}
304+
299305
private void LoadGitUser()
300306
{
301307
GitClient.GetConfigUserAndEmail()
302-
.Then((success, strings) => {
303-
var username = strings[0];
304-
var email = strings[1];
305-
306-
var user = new User {
307-
Name = username,
308-
Email = email
309-
};
310-
308+
.Then((success, user) => {
311309
Logger.Trace("OnGitUserLoaded: {0}", user);
312310
OnGitUserLoaded?.Invoke(user);
313-
314311
}).Start();
315312
}
316313

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public override void OnEnable()
6868
if (Repository != null)
6969
{
7070
Repository.CheckLocalAndRemoteBranchListChangedEvent(lastLocalAndRemoteBranchListChangedEvent);
71+
Repository.UpdateConfigData();
7172
}
7273
}
7374

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public override void OnEnable()
4343
if (Repository != null)
4444
{
4545
Repository.CheckCurrentBranchChangedEvent(lastCurrentBranchChangedEvent);
46-
Repository.CheckStatusChangedEvent(lastStatusChangedEvent);
46+
Repository.RefreshStatus();
4747
}
4848
}
4949

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ public override void OnEnable()
7373

7474
if (Repository != null)
7575
{
76-
Repository.CheckLogChangedEvent(lastLogChangedEvent);
77-
Repository.CheckStatusChangedEvent(lastStatusChangedEvent);
76+
Repository.RefreshLog();
77+
Repository.RefreshStatus();
7878
Repository.CheckCurrentRemoteChangedEvent(lastCurrentRemoteChangedEvent);
7979
}
8080
}

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,9 @@ private void CheckForUser()
9696
Logger.Trace("Checking for user");
9797
isBusy = true;
9898

99-
GitClient.GetConfigUserAndEmail().FinallyInUI((success, ex, strings) => {
100-
var username = strings[0];
101-
var email = strings[1];
102-
99+
GitClient.GetConfigUserAndEmail().FinallyInUI((success, ex, user) => {
103100
isBusy = false;
104-
isUserDataPresent = success && !String.IsNullOrEmpty(username) && !String.IsNullOrEmpty(email);
101+
isUserDataPresent = success && !String.IsNullOrEmpty(user.Name) && !String.IsNullOrEmpty(user.Email);
105102
hasCompletedInitialCheck = true;
106103

107104
Logger.Trace("User Present: {0}", isUserDataPresent);

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

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class UserSettingsView : Subview
2222
[SerializeField] private string gitEmail;
2323
[SerializeField] private string newGitName;
2424
[SerializeField] private string newGitEmail;
25-
[SerializeField] private User cachedUser;
2625

2726
public override void InitializeView(IView parent)
2827
{
@@ -63,15 +62,11 @@ public override void OnGUI()
6362
{
6463
if (Repository != null)
6564
{
66-
Repository.User.Name = newGitName;
65+
Repository.User.Name = gitName = newGitName;
6766
}
6867
else
6968
{
70-
if (cachedUser == null)
71-
{
72-
cachedUser = new User();
73-
}
74-
cachedUser.Name = newGitName;
69+
gitName = newGitName;
7570
}
7671
}
7772
})
@@ -83,11 +78,11 @@ public override void OnGUI()
8378
{
8479
if (Repository != null)
8580
{
86-
Repository.User.Email = newGitEmail;
81+
Repository.User.Email = gitEmail = newGitEmail;
8782
}
8883
else
8984
{
90-
cachedUser.Email = newGitEmail;
85+
gitEmail = newGitEmail;
9186
}
9287

9388
userDataHasChanged = true;
@@ -107,49 +102,53 @@ public override void OnGUI()
107102
EditorGUI.EndDisabledGroup();
108103
}
109104

105+
public override void OnEnable()
106+
{
107+
base.OnEnable();
108+
userDataHasChanged = true;
109+
}
110+
110111
private void MaybeUpdateData()
111112
{
112-
if (Repository == null)
113+
if (userDataHasChanged)
113114
{
114-
if (!String.IsNullOrEmpty(EntryPoint.Environment.GitExecutablePath))
115+
userDataHasChanged = false;
116+
117+
if (Repository == null)
115118
{
116-
if ((cachedUser == null || String.IsNullOrEmpty(cachedUser.Name)) && GitClient != null)
117-
{
118-
GitClient.GetConfigUserAndEmail().FinallyInUI((success, ex, strings) => {
119-
var username = strings[0];
120-
var email = strings[1];
121-
122-
if (success && !String.IsNullOrEmpty(username) && !String.IsNullOrEmpty(email))
123-
{
124-
cachedUser = new User {
125-
Name = username,
126-
Email = email
127-
};
128-
129-
userDataHasChanged = true;
130-
Redraw();
131-
}
132-
}).Start();
133-
}
119+
UpdateUserDataFromClient();
134120
}
135-
136-
if (userDataHasChanged)
121+
else
137122
{
138-
newGitName = gitName = cachedUser.Name;
139-
newGitEmail = gitEmail = cachedUser.Email;
140-
userDataHasChanged = false;
123+
newGitName = gitName = Repository.User.Name;
124+
newGitEmail = gitEmail = Repository.User.Email;
141125
}
142-
return;
143126
}
127+
}
144128

145-
userDataHasChanged = Repository.User.Name != gitName || Repository.User.Email != gitEmail;
129+
private void UpdateUserDataFromClient()
130+
{
131+
if (String.IsNullOrEmpty(EntryPoint.Environment.GitExecutablePath))
132+
{
133+
return;
134+
}
146135

147-
if (!userDataHasChanged)
136+
if (GitClient == null)
137+
{
148138
return;
139+
}
140+
141+
Logger.Trace("Update user data from GitClient");
149142

150-
userDataHasChanged = false;
151-
newGitName = gitName = Repository.User.Name;
152-
newGitEmail = gitEmail = Repository.User.Email;
143+
GitClient.GetConfigUserAndEmail()
144+
.ThenInUI((success, user) => {
145+
if (success && !String.IsNullOrEmpty(user.Name) && !String.IsNullOrEmpty(user.Email))
146+
{
147+
newGitName = gitName = user.Name;
148+
newGitEmail = gitEmail = user.Email;
149+
Redraw();
150+
}
151+
}).Start();
153152
}
154153

155154
public override bool IsBusy

0 commit comments

Comments
 (0)