From 6932ce44a95740b494374e96f4425c53b03e947a Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 18 Sep 2024 17:19:55 +0800 Subject: [PATCH] fix: new window opened on failing fetch due to missing `StrictHostKeyChecking=accept-new` for repo remote without private ssh key (#485) --- src/App.axaml.cs | 3 +++ src/Commands/Command.cs | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/App.axaml.cs b/src/App.axaml.cs index a434fa5e..090f060e 100644 --- a/src/App.axaml.cs +++ b/src/App.axaml.cs @@ -521,6 +521,9 @@ namespace SourceGit return false; var param = args[0]; + if (Directory.Exists(param)) + return false; + if (!param.StartsWith("enter passphrase", StringComparison.OrdinalIgnoreCase) && !param.Contains(" password", StringComparison.OrdinalIgnoreCase)) return false; diff --git a/src/Commands/Command.cs b/src/Commands/Command.cs index b347dc37..c30ba59b 100644 --- a/src/Commands/Command.cs +++ b/src/Commands/Command.cs @@ -59,9 +59,14 @@ namespace SourceGit.Commands // If an SSH private key was provided, sets the environment. if (!string.IsNullOrEmpty(SSHKey)) + { start.Environment.Add("GIT_SSH_COMMAND", $"ssh -o StrictHostKeyChecking=accept-new -i '{SSHKey}'"); + } else + { + start.Environment.Add("GIT_SSH_COMMAND", $"ssh -o StrictHostKeyChecking=accept-new"); start.Arguments += "-c credential.helper=manager "; + } // Force using en_US.UTF-8 locale to avoid GCM crash if (OperatingSystem.IsLinux())