From 1adf18c724348e49d98d0c41cf180eaeaa7db3c5 Mon Sep 17 00:00:00 2001 From: Gadfly Date: Wed, 5 Jun 2024 17:32:19 +0800 Subject: [PATCH] fix: remove null-check of sshKey in AddRemote and change command execution order --- src/ViewModels/AddRemote.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/ViewModels/AddRemote.cs b/src/ViewModels/AddRemote.cs index 84ca2326..8386b755 100644 --- a/src/ViewModels/AddRemote.cs +++ b/src/ViewModels/AddRemote.cs @@ -79,11 +79,8 @@ namespace SourceGit.ViewModels public static ValidationResult ValidateSSHKey(string sshkey, ValidationContext ctx) { - if (ctx.ObjectInstance is AddRemote add && add._useSSH) + if (ctx.ObjectInstance is AddRemote { _useSSH: true } && !string.IsNullOrEmpty(sshkey)) { - if (string.IsNullOrEmpty(sshkey)) - return new ValidationResult("SSH private key is required"); - if (!File.Exists(sshkey)) return new ValidationResult("Given SSH private key can NOT be found!"); } @@ -102,10 +99,9 @@ namespace SourceGit.ViewModels if (succ) { SetProgressDescription("Fetching from added remote ..."); - new Commands.Fetch(_repo.FullPath, _name, true, SetProgressDescription).Exec(); - - SetProgressDescription("Post processing ..."); new Commands.Config(_repo.FullPath).Set($"remote.{_name}.sshkey", _useSSH ? SSHKey : null); + + new Commands.Fetch(_repo.FullPath, _name, true, SetProgressDescription).Exec(); } CallUIThread(() => {