Merge pull request #167 from gadfly3173/fix/add-remote-ssh

fix: remove null-check of sshKey in AddRemote and change command execution order
This commit is contained in:
leo 2024-06-05 18:25:57 +08:00 committed by GitHub
commit 7d49d2b913
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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(() =>
{