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

Commit 45d44fe

Browse files
Cleanup
1 parent 692b7c6 commit 45d44fe

File tree

2 files changed

+27
-24
lines changed

2 files changed

+27
-24
lines changed

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

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -596,29 +596,31 @@ private void MaybeUpdateData()
596596

597597
if (keychainHasUpdate || currentRemoteHasUpdate)
598598
{
599-
Connection[] connections;
600-
if (HasRepository && !string.IsNullOrEmpty(Repository.CloneUrl))
599+
var username = String.Empty;
600+
if (Repository != null)
601601
{
602-
var host = Repository.CloneUrl
603-
.ToRepositoryUri()
604-
.GetComponents(UriComponents.Host, UriFormat.SafeUnescaped);
602+
Connection connection;
603+
if (!string.IsNullOrEmpty(Repository.CloneUrl))
604+
{
605+
var host = Repository.CloneUrl
606+
.ToRepositoryUri()
607+
.GetComponents(UriComponents.Host, UriFormat.SafeUnescaped);
605608

606-
connections = Platform.Keychain.Connections.OrderByDescending(x => x.Host == host).ToArray();
607-
}
608-
else
609-
{
610-
connections = Platform.Keychain.Connections.OrderByDescending(HostAddress.IsGitHubDotCom).ToArray();
611-
}
609+
connection = Platform.Keychain.Connections.FirstOrDefault(x => x.Host == host);
610+
}
611+
else
612+
{
613+
connection = Platform.Keychain.Connections.FirstOrDefault(HostAddress.IsGitHubDotCom);
614+
}
612615

613-
if (connections.Any())
614-
{
615-
currentUsername = connections.First().Username;
616-
}
617-
else
618-
{
619-
currentUsername = "";
616+
if (connection != null)
617+
{
618+
username = connection.Username;
619+
}
620620
}
621621

622+
currentUsername = username;
623+
622624
keychainHasUpdate = false;
623625
currentRemoteHasUpdate = false;
624626
}

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,22 +103,23 @@ private static void UpdateCurrentUsername()
103103
var username = String.Empty;
104104
if (Repository != null)
105105
{
106-
Connection[] connections;
106+
Connection connection;
107107
if (!string.IsNullOrEmpty(Repository.CloneUrl))
108108
{
109-
var host = Repository.CloneUrl.ToRepositoryUri()
109+
var host = Repository.CloneUrl
110+
.ToRepositoryUri()
110111
.GetComponents(UriComponents.Host, UriFormat.SafeUnescaped);
111112

112-
connections = Platform.Keychain.Connections.OrderByDescending(x => x.Host == host).ToArray();
113+
connection = Platform.Keychain.Connections.FirstOrDefault(x => x.Host == host);
113114
}
114115
else
115116
{
116-
connections = Platform.Keychain.Connections.OrderByDescending(HostAddress.IsGitHubDotCom).ToArray();
117+
connection = Platform.Keychain.Connections.FirstOrDefault(HostAddress.IsGitHubDotCom);
117118
}
118119

119-
if (connections.Any())
120+
if (connection != null)
120121
{
121-
username = connections.First().Username;
122+
username = connection.Username;
122123
}
123124
}
124125

0 commit comments

Comments
 (0)