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

Commit 6dc9f55

Browse files
Merge branch 'fixes/publish-view-disable-until-load' into fixes/publish-view-faster-load
# Conflicts: # src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PUblishView.cs
2 parents f1bfe84 + acc015a commit 6dc9f55

File tree

5 files changed

+28
-17
lines changed

5 files changed

+28
-17
lines changed

src/GitHub.Api/Application/ApiClient.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,15 @@ private async Task LogoutInternal(UriString host)
6161
public async Task CreateRepository(NewRepository newRepository, Action<Octokit.Repository, Exception> callback, string organization = null)
6262
{
6363
Guard.ArgumentNotNull(callback, "callback");
64-
await CreateRepositoryInternal(newRepository, callback, organization);
64+
try
65+
{
66+
var repository = await CreateRepositoryInternal(newRepository, organization);
67+
callback(repository, null);
68+
}
69+
catch (Exception e)
70+
{
71+
callback(null, e);
72+
}
6573
}
6674

6775
public async Task GetOrganizations(Action<IList<Organization>> callback)
@@ -181,16 +189,15 @@ public async Task<bool> ContinueLoginAsync(LoginResult loginResult, Func<LoginRe
181189
return result.Code == LoginResultCodes.Success;
182190
}
183191

184-
private async Task CreateRepositoryInternal(NewRepository newRepository, Action<Octokit.Repository, Exception> callback, string organization)
192+
private async Task<Octokit.Repository> CreateRepositoryInternal(NewRepository newRepository, string organization)
185193
{
186194
try
187195
{
188196
logger.Trace("Creating repository");
189197

190198
if (!await LoadKeychainInternal())
191199
{
192-
callback(null, new Exception("Keychain Not Loaded"));
193-
return;
200+
return null;
194201
}
195202

196203
Octokit.Repository repository;
@@ -208,13 +215,12 @@ private async Task CreateRepositoryInternal(NewRepository newRepository, Action<
208215
}
209216

210217
logger.Trace("Created Repository");
211-
212-
callback(repository, null);
218+
return repository;
213219
}
214220
catch (Exception ex)
215221
{
216222
logger.Error(ex, "Error Creating Repository");
217-
callback(null, ex);
223+
throw;
218224
}
219225
}
220226

src/GitHub.Api/Metrics/UsageTracker.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ private async Task SendUsage()
145145
}
146146
catch (Exception ex)
147147
{
148-
Logger.Warning(ex, "Error Sending Usage");
148+
Logger.Warning(@"Error Sending Usage Exception Type:""{0}"" Message:""{1}""", ex.GetType().ToString(), ex.Message);
149149
}
150150
}
151151

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ private static void Initialize()
3737

3838
if (ApplicationCache.Instance.FirstRun)
3939
{
40-
Debug.Log("Initializing GitHub for Unity version " + ApplicationInfo.Version);
40+
Debug.Log("Initialized GitHub for Unity version " + ApplicationInfo.Version);
4141

4242
var oldLogPath = logPath.Parent.Combine(logPath.FileNameWithoutExtension + "-old" + logPath.ExtensionWithDot);
4343
try
@@ -53,7 +53,7 @@ private static void Initialize()
5353
Logging.Error(ex, "Error rotating log files");
5454
}
5555

56-
Debug.Log("Initializing GitHub for Unity log file: " + logPath);
56+
Debug.Log("Initialized GitHub for Unity log file: " + logPath);
5757
}
5858
Logging.LogAdapter = new FileLogAdapter(logPath);
5959
Logging.Info("Initializing GitHub for Unity version " + ApplicationInfo.Version);

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,22 +75,25 @@ private void PopulateView()
7575
Client.LoadKeychain(hasKeys => {
7676
if (!hasKeys)
7777
{
78+
Logger.Warning("Unable to get current user");
79+
isBusy = false;
7880
return;
7981
}
8082

8183
//TODO: ONE_USER_LOGIN This assumes only ever one user can login
8284
username = keychainConnections.First().Username;
8385

8486
Client.GetOrganizations(organizations => {
87+
Logger.Trace("Loaded {0} organizations", organizations.Count);
8588

8689
var organizationLogins = organizations
8790
.OrderBy(organization => organization.Login)
8891
.Select(organization => organization.Login);
8992

9093
owners = new[] { username }.Union(organizationLogins).ToArray();
94+
95+
isBusy = false;
9196
});
92-
}).Finally(task => {
93-
isBusy = false;
9497
});
9598
}
9699
else
@@ -217,7 +220,7 @@ public override void OnGUI()
217220

218221
GitClient.RemoteAdd("origin", repository.CloneUrl)
219222
.Then(GitClient.Push("origin", Repository.CurrentBranch.Value.Name))
220-
.ThenInUI(Parent.Finish)
223+
.ThenInUI(Finish)
221224
.Start();
222225
}, organization);
223226
}

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ class SettingsView : Subview
6767
private const string DefaultRepositoryRemoteName = "origin";
6868

6969
[NonSerialized] private int newGitIgnoreRulesSelection = -1;
70-
[NonSerialized] private ConfigRemote? activeRemote;
7170

7271
[SerializeField] private string gitName;
7372
[SerializeField] private string gitEmail;
@@ -94,6 +93,8 @@ public override void OnEnable()
9493
{
9594
base.OnEnable();
9695
AttachHandlers(Repository);
96+
97+
remoteHasChanged = true;
9798
}
9899

99100
public override void OnDisable()
@@ -114,8 +115,9 @@ public override void OnRepositoryChanged(IRepository oldRepository)
114115

115116
DetachHandlers(oldRepository);
116117
AttachHandlers(Repository);
117-
activeRemote = Repository.CurrentRemote;
118+
118119
remoteHasChanged = true;
120+
119121
Refresh();
120122
}
121123

@@ -178,7 +180,7 @@ private void MaybeUpdateData()
178180

179181
if (Repository == null)
180182
{
181-
if (cachedUser == null || String.IsNullOrEmpty(cachedUser.Name))
183+
if ((cachedUser == null || String.IsNullOrEmpty(cachedUser.Name)) && GitClient != null)
182184
{
183185
var user = new User();
184186
GitClient.GetConfig("user.name", GitConfigSource.User)
@@ -221,6 +223,7 @@ private void MaybeUpdateData()
221223
if (remoteHasChanged)
222224
{
223225
remoteHasChanged = false;
226+
var activeRemote = Repository.CurrentRemote;
224227
hasRemote = activeRemote.HasValue && !String.IsNullOrEmpty(activeRemote.Value.Url);
225228
if (!hasRemote)
226229
{
@@ -245,7 +248,6 @@ private void ResetToDefaults()
245248

246249
private void Repository_OnActiveRemoteChanged(string remote)
247250
{
248-
activeRemote = Repository.CurrentRemote;
249251
remoteHasChanged = true;
250252
}
251253

0 commit comments

Comments
 (0)