mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
optimize<Command>: each process has its own envs
This commit is contained in:
parent
75a46ceb74
commit
48020861ee
5 changed files with 11 additions and 4 deletions
|
@ -14,7 +14,7 @@ namespace SourceGit.Commands {
|
||||||
handler = outputHandler;
|
handler = outputHandler;
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(sshKey)) {
|
if (!string.IsNullOrEmpty(sshKey)) {
|
||||||
Environment.SetEnvironmentVariable("GIT_SSH_COMMAND", $"ssh -i '{sshKey}'");
|
Envs.Add("GIT_SSH_COMMAND", $"ssh -i '{sshKey}'");
|
||||||
Args = "";
|
Args = "";
|
||||||
} else {
|
} else {
|
||||||
Args = "-c credential.helper=manager ";
|
Args = "-c credential.helper=manager ";
|
||||||
|
|
|
@ -52,6 +52,11 @@ namespace SourceGit.Commands {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool TraitErrorAsOutput { get; set; } = false;
|
public bool TraitErrorAsOutput { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用于设置该进程独有的环境变量
|
||||||
|
/// </summary>
|
||||||
|
public Dictionary<string, string> Envs { get; set; } = new Dictionary<string, string>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 运行
|
/// 运行
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -68,6 +73,8 @@ namespace SourceGit.Commands {
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(Cwd)) start.WorkingDirectory = Cwd;
|
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 progressFilter = new Regex(@"\s\d+%\s");
|
||||||
var errs = new List<string>();
|
var errs = new List<string>();
|
||||||
var proc = new Process() { StartInfo = start };
|
var proc = new Process() { StartInfo = start };
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace SourceGit.Commands {
|
||||||
|
|
||||||
var sshKey = new Config(repo).Get($"remote.{remote}.sshkey");
|
var sshKey = new Config(repo).Get($"remote.{remote}.sshkey");
|
||||||
if (!string.IsNullOrEmpty(sshKey)) {
|
if (!string.IsNullOrEmpty(sshKey)) {
|
||||||
Environment.SetEnvironmentVariable("GIT_SSH_COMMAND", $"ssh -i '{sshKey}'");
|
Envs.Add("GIT_SSH_COMMAND", $"ssh -i '{sshKey}'");
|
||||||
Args = "";
|
Args = "";
|
||||||
} else {
|
} else {
|
||||||
Args = "-c credential.helper=manager ";
|
Args = "-c credential.helper=manager ";
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace SourceGit.Commands {
|
||||||
|
|
||||||
var sshKey = new Config(repo).Get($"remote.{remote}.sshkey");
|
var sshKey = new Config(repo).Get($"remote.{remote}.sshkey");
|
||||||
if (!string.IsNullOrEmpty(sshKey)) {
|
if (!string.IsNullOrEmpty(sshKey)) {
|
||||||
Environment.SetEnvironmentVariable("GIT_SSH_COMMAND", $"ssh -i '{sshKey}'");
|
Envs.Add("GIT_SSH_COMMAND", $"ssh -i '{sshKey}'");
|
||||||
Args = "";
|
Args = "";
|
||||||
} else {
|
} else {
|
||||||
Args = "-c credential.helper=manager ";
|
Args = "-c credential.helper=manager ";
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace SourceGit.Commands {
|
||||||
|
|
||||||
var sshKey = new Config(repo).Get($"remote.{remote}.sshkey");
|
var sshKey = new Config(repo).Get($"remote.{remote}.sshkey");
|
||||||
if (!string.IsNullOrEmpty(sshKey)) {
|
if (!string.IsNullOrEmpty(sshKey)) {
|
||||||
Environment.SetEnvironmentVariable("GIT_SSH_COMMAND", $"ssh -i '{sshKey}'");
|
Envs.Add("GIT_SSH_COMMAND", $"ssh -i '{sshKey}'");
|
||||||
Args = "";
|
Args = "";
|
||||||
} else {
|
} else {
|
||||||
Args = "-c credential.helper=manager ";
|
Args = "-c credential.helper=manager ";
|
||||||
|
|
Loading…
Reference in a new issue