feature<SSH>: supports using ssh private key to access remote git repository

This commit is contained in:
leo 2021-10-12 17:14:48 +08:00
parent 306292147f
commit 75a46ceb74
11 changed files with 200 additions and 18 deletions

View file

@ -8,12 +8,20 @@ namespace SourceGit.Commands {
public class Clone : Command {
private Action<string> handler = null;
public Clone(string path, string url, string localName, string extraArgs, Action<string> outputHandler) {
public Clone(string path, string url, string localName, string sshKey, string extraArgs, Action<string> outputHandler) {
Cwd = path;
TraitErrorAsOutput = true;
Args = "-c credential.helper=manager clone --progress --verbose --recurse-submodules ";
handler = outputHandler;
if (!string.IsNullOrEmpty(sshKey)) {
Environment.SetEnvironmentVariable("GIT_SSH_COMMAND", $"ssh -i '{sshKey}'");
Args = "";
} else {
Args = "-c credential.helper=manager ";
}
Args += "clone --progress --verbose --recurse-submodules ";
if (!string.IsNullOrEmpty(extraArgs)) Args += $"{extraArgs} ";
Args += $"{url} ";
if (!string.IsNullOrEmpty(localName)) Args += localName;