Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure we create a WindowsProcessManager on Windows #1146

Merged
merged 1 commit into from
Mar 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/shared/Core/CommandContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public CommandContext()
FileSystem = new WindowsFileSystem();
SessionManager = new WindowsSessionManager();
Environment = new WindowsEnvironment(FileSystem);
ProcessManager = new ProcessManager(Trace2);
ProcessManager = new WindowsProcessManager(Trace2);
Terminal = new WindowsTerminal(Trace);
string gitPath = GetGitPath(Environment, FileSystem, Trace);
Git = new GitProcess(
Expand All @@ -120,7 +120,7 @@ public CommandContext()
FileSystem = new MacOSFileSystem();
SessionManager = new MacOSSessionManager();
Environment = new MacOSEnvironment(FileSystem);
ProcessManager = new WindowsProcessManager(Trace2);
ProcessManager = new ProcessManager(Trace2);
Terminal = new MacOSTerminal(Trace);
string gitPath = GetGitPath(Environment, FileSystem, Trace);
Git = new GitProcess(
Expand Down
8 changes: 2 additions & 6 deletions src/shared/Core/Interop/Windows/WindowsProcessManager.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
using System.Diagnostics;

namespace GitCredentialManager.Interop.Windows;

public class WindowsProcessManager : ProcessManager
{
private readonly ITrace2 _trace2;

public WindowsProcessManager(ITrace2 trace2) : base(trace2)
{
_trace2 = trace2;
PlatformUtils.EnsureWindows();
}

public override ChildProcess CreateProcess(string path, string args, bool useShellExecute, string workingDirectory)
Expand All @@ -17,7 +13,7 @@ public override ChildProcess CreateProcess(string path, string args, bool useShe
if (!useShellExecute && WslUtils.IsWslPath(path))
{
string wslPath = WslUtils.ConvertToDistroPath(path, out string distro);
return WslUtils.CreateWslProcess(distro, $"{wslPath} {args}", _trace2, workingDirectory);
return WslUtils.CreateWslProcess(distro, $"{wslPath} {args}", Trace2, workingDirectory);
}

return base.CreateProcess(path, args, useShellExecute, workingDirectory);
Expand Down
8 changes: 5 additions & 3 deletions src/shared/Core/ProcessManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ public interface IProcessManager

public class ProcessManager : IProcessManager
{
private readonly ITrace2 _trace2;
protected readonly ITrace2 Trace2;

public ProcessManager(ITrace2 trace2)
{
_trace2 = trace2;
EnsureArgument.NotNull(trace2, nameof(trace2));

Trace2 = trace2;
}

public virtual ChildProcess CreateProcess(string path, string args, bool useShellExecute, string workingDirectory)
Expand All @@ -51,6 +53,6 @@ public virtual ChildProcess CreateProcess(string path, string args, bool useShel

public virtual ChildProcess CreateProcess(ProcessStartInfo psi)
{
return new ChildProcess(_trace2, psi);
return new ChildProcess(Trace2, psi);
}
}