fix: commit stucks when using SSH formatted GPG signing with a key contains non-empty passphrase

This commit is contained in:
leo 2024-07-09 17:56:23 +08:00
parent 386c92fa28
commit 9db050e8c2
No known key found for this signature in database
5 changed files with 19 additions and 19 deletions

View file

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using Avalonia.Threading;
namespace SourceGit.Commands
@ -38,11 +39,16 @@ namespace SourceGit.Commands
public Dictionary<string, string> Envs { get; set; } = new Dictionary<string, string>();
public void UseSSHKey(string key)
{
UseSSHAskpass();
Envs.Add("GIT_SSH_COMMAND", $"ssh -i '{key}'");
}
public void UseSSHAskpass()
{
Envs.Add("DISPLAY", "required");
Envs.Add("SSH_ASKPASS", $"\"{Process.GetCurrentProcess().MainModule.FileName}\" --askpass");
Envs.Add("SSH_ASKPASS_REQUIRE", "prefer");
Envs.Add("GIT_SSH_COMMAND", $"ssh -i '{key}'");
}
public bool Exec()