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

Commit 986f3ed

Browse files
Merge branch 'features/octorun-js' into fixes/remove-octokit-and-octorun
# Conflicts: # src/GitHub.Api/Authentication/LoginManager.cs # src/UnityExtension/Assets/Editor/GitHub.Unity/GitHub.Unity.csproj
2 parents f9d928c + fb3b542 commit 986f3ed

File tree

3 files changed

+30
-14
lines changed

3 files changed

+30
-14
lines changed

src/GitHub.Api/Application/ApplicationManagerBase.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ public void Run(bool firstRun)
5050
Logger.Trace("Using octorunScriptPath: {0}", octorunScriptPath);
5151

5252
var gitExecutablePath = SystemSettings.Get(Constants.GitInstallPathKey)?.ToNPath();
53-
if (gitExecutablePath != null && gitExecutablePath.Value.FileExists()) // we have a git path
53+
if (gitExecutablePath.HasValue && gitExecutablePath.Value.FileExists()) // we have a git path
5454
{
5555
Logger.Trace("Using git install path from settings: {0}", gitExecutablePath);
56-
InitializeEnvironment(gitExecutablePath, octorunScriptPath);
56+
InitializeEnvironment(gitExecutablePath.Value, octorunScriptPath);
5757
}
5858
else // we need to go find git
5959
{
@@ -62,7 +62,7 @@ public void Run(bool firstRun)
6262
var initEnvironmentTask = new ActionTask<NPath>(CancellationToken, (_, path) => InitializeEnvironment(path, octorunScriptPath)) { Affinity = TaskAffinity.UI };
6363
var findExecTask = new FindExecTask("git", CancellationToken)
6464
.FinallyInUI((b, ex, path) => {
65-
if (b && path != null)
65+
if (b && path.IsInitialized)
6666
{
6767
Logger.Trace("FindExecTask Success: {0}", path);
6868
InitializeEnvironment(path, octorunScriptPath);

src/GitHub.Api/Authentication/LoginManager.cs

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ class LoginManager : ILoginManager
2626
private readonly string clientSecret;
2727
private readonly IProcessManager processManager;
2828
private readonly ITaskManager taskManager;
29-
private readonly NPath nodeJsExecutablePath;
30-
private readonly NPath octorunScript;
29+
private readonly NPath? nodeJsExecutablePath;
30+
private readonly NPath? octorunScript;
3131

3232
/// <summary>
3333
/// Initializes a new instance of the <see cref="LoginManager"/> class.
@@ -43,7 +43,7 @@ public LoginManager(
4343
IKeychain keychain,
4444
string clientId,
4545
string clientSecret,
46-
IProcessManager processManager = null, ITaskManager taskManager = null, NPath nodeJsExecutablePath = null, NPath octorunScript = null)
46+
IProcessManager processManager = null, ITaskManager taskManager = null, NPath? nodeJsExecutablePath = null, NPath? octorunScript = null)
4747
{
4848
Guard.ArgumentNotNull(keychain, nameof(keychain));
4949
Guard.ArgumentNotNullOrWhiteSpace(clientId, nameof(clientId));
@@ -149,9 +149,19 @@ private async Task<string> TryLogin(
149149
string password
150150
)
151151
{
152-
var loginTask = new OctorunTask(taskManager.Token, nodeJsExecutablePath, octorunScript,
152+
if (!nodeJsExecutablePath.HasValue)
153+
{
154+
throw new InvalidOperationException("nodeJsExecutablePath must be set");
155+
}
156+
157+
if (!octorunScript.HasValue)
158+
{
159+
throw new InvalidOperationException("octorunScript must be set");
160+
}
161+
162+
var loginTask = new OctorunTask(taskManager.Token, nodeJsExecutablePath.Value, octorunScript.Value,
153163
"login", ApplicationInfo.ClientId, ApplicationInfo.ClientSecret);
154-
loginTask.Configure(processManager, workingDirectory: octorunScript.Parent.Parent, withInput: true);
164+
loginTask.Configure(processManager, workingDirectory: octorunScript.Value.Parent.Parent, withInput: true);
155165
loginTask.OnStartProcess += proc =>
156166
{
157167
proc.StandardInput.WriteLine(username);
@@ -193,11 +203,19 @@ private async Task<string> TryContinueLogin(
193203
string code
194204
)
195205
{
196-
logger.Info("Continue Username:{0} {1} {2}", username, password, code);
206+
if (!nodeJsExecutablePath.HasValue)
207+
{
208+
throw new InvalidOperationException("nodeJsExecutablePath must be set");
209+
}
210+
211+
if (!octorunScript.HasValue)
212+
{
213+
throw new InvalidOperationException("octorunScript must be set");
214+
}
197215

198-
var loginTask = new OctorunTask(taskManager.Token, nodeJsExecutablePath, octorunScript,
216+
var loginTask = new OctorunTask(taskManager.Token, nodeJsExecutablePath.Value, octorunScript.Value,
199217
"login --twoFactor", ApplicationInfo.ClientId, ApplicationInfo.ClientSecret);
200-
loginTask.Configure(processManager, workingDirectory: octorunScript.Parent.Parent, withInput: true);
218+
loginTask.Configure(processManager, workingDirectory: octorunScript.Value.Parent.Parent, withInput: true);
201219
loginTask.OnStartProcess += proc =>
202220
{
203221
proc.StandardInput.WriteLine(username);
@@ -208,8 +226,6 @@ string code
208226

209227
var ret = (await loginTask.StartAwait());
210228

211-
logger.Trace("Return: {0}", string.Join(";", ret.ToArray()));
212-
213229
if (ret.Count == 0)
214230
{
215231
throw new Exception("Authentication failed");

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ private void SignOut(object obj)
451451
host = UriString.ToUriString(HostAddress.GitHubDotComHostAddress.WebUri);
452452
}
453453

454-
var apiClient = ApiClient.Create(host, Platform.Keychain, null, null, null, null);
454+
var apiClient = ApiClient.Create(host, Platform.Keychain, null, null, NPath.Default, NPath.Default);
455455
apiClient.Logout(host);
456456
}
457457

0 commit comments

Comments
 (0)