mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 12:15:00 +00:00
optimize<SSH>: using core.sshCommand instead of environment parameter GIT_SSH_COMMAND
This commit is contained in:
parent
fc43edb6d2
commit
1c10d9a286
6 changed files with 16 additions and 30 deletions
|
@ -15,9 +15,8 @@ namespace SourceGit.Commands {
|
|||
handler = outputHandler;
|
||||
onError = errHandler;
|
||||
|
||||
if (!string.IsNullOrEmpty(sshKey)) {
|
||||
Envs.Add("GIT_SSH_COMMAND", $"ssh -i '{sshKey}'");
|
||||
Args = "";
|
||||
if (string.IsNullOrEmpty(sshKey)) {
|
||||
Args = $"-c core.sshCommand=\"ssh -i '{sshKey}'\" ";
|
||||
} else {
|
||||
Args = "-c credential.helper=manager ";
|
||||
}
|
||||
|
|
|
@ -52,11 +52,6 @@ namespace SourceGit.Commands {
|
|||
/// </summary>
|
||||
public bool TraitErrorAsOutput { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 用于设置该进程独有的环境变量
|
||||
/// </summary>
|
||||
public Dictionary<string, string> Envs { get; set; } = new Dictionary<string, string>();
|
||||
|
||||
/// <summary>
|
||||
/// 运行
|
||||
/// </summary>
|
||||
|
@ -73,8 +68,6 @@ namespace SourceGit.Commands {
|
|||
|
||||
if (!string.IsNullOrEmpty(Cwd)) start.WorkingDirectory = Cwd;
|
||||
|
||||
foreach (var kv in Envs) start.EnvironmentVariables[kv.Key] = kv.Value;
|
||||
|
||||
var progressFilter = new Regex(@"\s\d+%\s");
|
||||
var errs = new List<string>();
|
||||
var proc = new Process() { StartInfo = start };
|
||||
|
|
|
@ -16,8 +16,7 @@ namespace SourceGit.Commands {
|
|||
|
||||
var sshKey = new Config(repo).Get($"remote.{remote}.sshkey");
|
||||
if (!string.IsNullOrEmpty(sshKey)) {
|
||||
Envs.Add("GIT_SSH_COMMAND", $"ssh -i '{sshKey}'");
|
||||
Args = "";
|
||||
Args = $"-c core.sshCommand=\"ssh -i '{sshKey}'\" ";
|
||||
} else {
|
||||
Args = "-c credential.helper=manager ";
|
||||
}
|
||||
|
@ -35,8 +34,7 @@ namespace SourceGit.Commands {
|
|||
|
||||
var sshKey = new Config(repo).Get($"remote.{remote}.sshkey");
|
||||
if (!string.IsNullOrEmpty(sshKey)) {
|
||||
Envs.Add("GIT_SSH_COMMAND", $"ssh -i '{sshKey}'");
|
||||
Args = "";
|
||||
Args = $"-c core.sshCommand=\"ssh -i '{sshKey}'\" ";
|
||||
} else {
|
||||
Args = "-c credential.helper=manager ";
|
||||
}
|
||||
|
|
|
@ -17,8 +17,7 @@ namespace SourceGit.Commands {
|
|||
|
||||
var sshKey = new Config(repo).Get($"remote.{remote}.sshkey");
|
||||
if (!string.IsNullOrEmpty(sshKey)) {
|
||||
Envs.Add("GIT_SSH_COMMAND", $"ssh -i '{sshKey}'");
|
||||
Args = "";
|
||||
Args = $"-c core.sshCommand=\"ssh -i '{sshKey}'\" ";
|
||||
} else {
|
||||
Args = "-c credential.helper=manager ";
|
||||
}
|
||||
|
|
|
@ -14,8 +14,7 @@ namespace SourceGit.Commands {
|
|||
|
||||
var sshKey = new Config(repo).Get($"remote.{remote}.sshkey");
|
||||
if (!string.IsNullOrEmpty(sshKey)) {
|
||||
Envs.Add("GIT_SSH_COMMAND", $"ssh -i '{sshKey}'");
|
||||
Args = "";
|
||||
Args = $"-c core.sshCommand=\"ssh -i '{sshKey}'\" ";
|
||||
} else {
|
||||
Args = "-c credential.helper=manager ";
|
||||
}
|
||||
|
@ -34,8 +33,7 @@ namespace SourceGit.Commands {
|
|||
|
||||
var sshKey = new Config(repo).Get($"remote.{remote}.sshkey");
|
||||
if (!string.IsNullOrEmpty(sshKey)) {
|
||||
Envs.Add("GIT_SSH_COMMAND", $"ssh -i '{sshKey}'");
|
||||
Args = "";
|
||||
Args = $"-c core.sshCommand=\"ssh -i '{sshKey}'\" ";
|
||||
} else {
|
||||
Args = "-c credential.helper=manager ";
|
||||
}
|
||||
|
@ -48,8 +46,7 @@ namespace SourceGit.Commands {
|
|||
|
||||
var sshKey = new Config(repo).Get($"remote.{remote}.sshkey");
|
||||
if (!string.IsNullOrEmpty(sshKey)) {
|
||||
Envs.Add("GIT_SSH_COMMAND", $"ssh -i '{sshKey}'");
|
||||
Args = "";
|
||||
Args = $"-c core.sshCommand=\"ssh -i '{sshKey}'\" ";
|
||||
} else {
|
||||
Args = "-c credential.helper=manager ";
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue