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

Commit bb7ef0b

Browse files
committed
Merge fixes/switching-views into branches-view
2 parents 98ca39f + 8696617 commit bb7ef0b

File tree

12 files changed

+120
-108
lines changed

12 files changed

+120
-108
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: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,6 @@ public override void InitializeView(IView parent)
5656
targetMode = mode;
5757
}
5858

59-
private void RepositoryOnLocalAndRemoteBranchListChanged(CacheUpdateEvent cacheUpdateEvent)
60-
{
61-
if (!lastLocalAndRemoteBranchListChangedEvent.Equals(cacheUpdateEvent))
62-
{
63-
new ActionTask(TaskManager.Token, () =>
64-
{
65-
lastLocalAndRemoteBranchListChangedEvent = cacheUpdateEvent;
66-
localAndRemoteBranchListHasUpdate = true;
67-
Redraw();
68-
})
69-
{ Affinity = TaskAffinity.UI }.Start();
70-
}
71-
}
7259

7360
public override void OnEnable()
7461
{
@@ -77,6 +64,7 @@ public override void OnEnable()
7764
if (Repository != null)
7865
{
7966
Repository.CheckLocalAndRemoteBranchListChangedEvent(lastLocalAndRemoteBranchListChangedEvent);
67+
Repository.UpdateConfigData();
8068
}
8169
}
8270

@@ -92,6 +80,16 @@ public override void OnDataUpdate()
9280
MaybeUpdateData();
9381
}
9482

83+
private void RepositoryOnLocalAndRemoteBranchListChanged(CacheUpdateEvent cacheUpdateEvent)
84+
{
85+
if (!lastLocalAndRemoteBranchListChangedEvent.Equals(cacheUpdateEvent))
86+
{
87+
lastLocalAndRemoteBranchListChangedEvent = cacheUpdateEvent;
88+
localAndRemoteBranchListHasUpdate = true;
89+
Redraw();
90+
}
91+
}
92+
9593
private void MaybeUpdateData()
9694
{
9795
if (localAndRemoteBranchListHasUpdate)
@@ -114,16 +112,11 @@ public override void OnGUI()
114112

115113
private void AttachHandlers(IRepository repository)
116114
{
117-
if (repository == null)
118-
return;
119-
120115
repository.LocalAndRemoteBranchListChanged += RepositoryOnLocalAndRemoteBranchListChanged;
121116
}
122117

123118
private void DetachHandlers(IRepository repository)
124119
{
125-
if (repository == null)
126-
return;
127120

128121
repository.LocalAndRemoteBranchListChanged -= RepositoryOnLocalAndRemoteBranchListChanged;
129122
}

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/SettingsView.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,8 @@ public override void OnEnable()
5151
userSettingsView.OnEnable();
5252
AttachHandlers(Repository);
5353

54-
if (Repository != null)
55-
{
56-
Repository.CheckCurrentRemoteChangedEvent(lastCurrentRemoteChangedEvent);
57-
Repository.CheckLocksChangedEvent(lastLocksChangedEvent);
58-
}
59-
54+
Repository.CheckCurrentRemoteChangedEvent(lastCurrentRemoteChangedEvent);
55+
Repository.CheckLocksChangedEvent(lastLocksChangedEvent);
6056
metricsHasChanged = true;
6157
}
6258

0 commit comments

Comments
 (0)