enhance: set GIT_SSH_COMMAND only if it has not been provided (#544)
Some checks are pending
Continuous Integration / Build (push) Waiting to run
Continuous Integration / Prepare version string (push) Waiting to run
Continuous Integration / Package (push) Blocked by required conditions

This commit is contained in:
leo 2024-10-08 16:19:03 +08:00
parent 3951549e5c
commit 8ddf6e87e9
No known key found for this signature in database

View file

@ -188,10 +188,8 @@ namespace SourceGit.Commands
start.Environment.Add("SOURCEGIT_LAUNCH_AS_ASKPASS", "TRUE"); start.Environment.Add("SOURCEGIT_LAUNCH_AS_ASKPASS", "TRUE");
// If an SSH private key was provided, sets the environment. // If an SSH private key was provided, sets the environment.
if (!string.IsNullOrEmpty(SSHKey)) if (!start.Environment.ContainsKey("GIT_SSH_COMMAND") && !string.IsNullOrEmpty(SSHKey))
start.Environment.Add("GIT_SSH_COMMAND", $"ssh -o StrictHostKeyChecking=accept-new -i '{SSHKey}'"); start.Environment.Add("GIT_SSH_COMMAND", $"ssh -i '{SSHKey}'");
else
start.Environment.Add("GIT_SSH_COMMAND", $"ssh -o StrictHostKeyChecking=accept-new");
// Force using en_US.UTF-8 locale to avoid GCM crash // Force using en_US.UTF-8 locale to avoid GCM crash
if (OperatingSystem.IsLinux()) if (OperatingSystem.IsLinux())
@ -201,14 +199,9 @@ namespace SourceGit.Commands
if (OperatingSystem.IsMacOS()) if (OperatingSystem.IsMacOS())
{ {
if (start.Environment.TryGetValue("PATH", out var path)) if (start.Environment.TryGetValue("PATH", out var path))
{ start.Environment.Add("PATH", $"/opt/homebrew/bin:/opt/homebrew/sbin:{path}");
path = "/opt/homebrew/bin:/opt/homebrew/sbin:" + path;
}
else else
{ start.Environment.Add("PATH", "/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin");
path = "/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin";
}
start.Environment.Add("PATH", path);
} }
// Force using this app as git editor. // Force using this app as git editor.