command: Move Git logic out of SSH and derive from SSH command
This commit is contained in:
parent
77ed294bfd
commit
73f472e997
|
@ -19,7 +19,7 @@ using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace Sparkles.Git {
|
namespace Sparkles.Git {
|
||||||
|
|
||||||
public class GitCommand : Command {
|
public class GitCommand : SSHCommand {
|
||||||
|
|
||||||
public static string ExecPath;
|
public static string ExecPath;
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ namespace Sparkles.Git {
|
||||||
string GIT_SSH_COMMAND = SSHCommand.SSHCommandPath;
|
string GIT_SSH_COMMAND = SSHCommand.SSHCommandPath;
|
||||||
|
|
||||||
if (auth_info != null)
|
if (auth_info != null)
|
||||||
GIT_SSH_COMMAND = SSHCommand.FormatGitSSHCommand (auth_info);
|
GIT_SSH_COMMAND = FormatGitSSHCommand (auth_info);
|
||||||
|
|
||||||
if (ExecPath != null)
|
if (ExecPath != null)
|
||||||
SetEnvironmentVariable ("GIT_EXEC_PATH", ExecPath);
|
SetEnvironmentVariable ("GIT_EXEC_PATH", ExecPath);
|
||||||
|
@ -208,5 +208,16 @@ namespace Sparkles.Git {
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static string FormatGitSSHCommand (SSHAuthenticationInfo auth_info)
|
||||||
|
{
|
||||||
|
return SSHCommandPath + " " +
|
||||||
|
"-i " + auth_info.PrivateKeyFilePath.Replace ("\\", "/").Replace (" ", "\\ ") + " " +
|
||||||
|
"-o UserKnownHostsFile=" + auth_info.KnownHostsFilePath.Replace ("\\", "/").Replace (" ", "\\ ") + " " +
|
||||||
|
"-o IdentitiesOnly=yes" + " " + // Don't fall back to other keys on the system
|
||||||
|
"-o PasswordAuthentication=no" + " " + // Don't hang on possible password prompts
|
||||||
|
"-F /dev/null"; // Ignore the system's SSH config file
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -416,7 +416,7 @@ namespace Sparkles.Git {
|
||||||
{
|
{
|
||||||
var git_config_required = new GitCommand (TargetFolder, "config filter.lfs.required true");
|
var git_config_required = new GitCommand (TargetFolder, "config filter.lfs.required true");
|
||||||
|
|
||||||
string GIT_SSH_COMMAND = SSHCommand.FormatGitSSHCommand (auth_info);
|
string GIT_SSH_COMMAND = GitCommand.FormatGitSSHCommand (auth_info);
|
||||||
string smudge_command;
|
string smudge_command;
|
||||||
string clean_command;
|
string clean_command;
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ namespace Sparkles.Git {
|
||||||
git_config = new GitCommand (LocalPath, "config remote.origin.url \"" + RemoteUrl + "\"");
|
git_config = new GitCommand (LocalPath, "config remote.origin.url \"" + RemoteUrl + "\"");
|
||||||
git_config.StartAndWaitForExit ();
|
git_config.StartAndWaitForExit ();
|
||||||
|
|
||||||
git_config = new GitCommand (LocalPath, "config core.sshCommand " + SSHCommand.FormatGitSSHCommand (auth_info));
|
git_config = new GitCommand (LocalPath, "config core.sshCommand " + GitCommand.FormatGitSSHCommand (auth_info));
|
||||||
git_config.StartAndWaitForExit();
|
git_config.StartAndWaitForExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,13 +210,13 @@ namespace Sparkles.Git {
|
||||||
if (InstallationInfo.OperatingSystem == OS.Mac || InstallationInfo.OperatingSystem == OS.Windows) {
|
if (InstallationInfo.OperatingSystem == OS.Mac || InstallationInfo.OperatingSystem == OS.Windows) {
|
||||||
pre_push_hook_content =
|
pre_push_hook_content =
|
||||||
"#!/bin/sh" + Environment.NewLine +
|
"#!/bin/sh" + Environment.NewLine +
|
||||||
"env GIT_SSH_COMMAND='" + SSHCommand.FormatGitSSHCommand (auth_info) + "' " +
|
"env GIT_SSH_COMMAND='" + GitCommand.FormatGitSSHCommand (auth_info) + "' " +
|
||||||
Path.Combine (Configuration.DefaultConfiguration.BinPath, "git-lfs").Replace ("\\", "/") + " pre-push \"$@\"";
|
Path.Combine (Configuration.DefaultConfiguration.BinPath, "git-lfs").Replace ("\\", "/") + " pre-push \"$@\"";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
pre_push_hook_content =
|
pre_push_hook_content =
|
||||||
"#!/bin/sh" + Environment.NewLine +
|
"#!/bin/sh" + Environment.NewLine +
|
||||||
"env GIT_SSH_COMMAND='" + SSHCommand.FormatGitSSHCommand (auth_info) + "' " +
|
"env GIT_SSH_COMMAND='" + GitCommand.FormatGitSSHCommand (auth_info) + "' " +
|
||||||
"git-lfs pre-push \"$@\"";
|
"git-lfs pre-push \"$@\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,23 +38,6 @@ namespace Sparkles {
|
||||||
public SSHCommand(string command, string args, SSHAuthenticationInfo auth_info) :
|
public SSHCommand(string command, string args, SSHAuthenticationInfo auth_info) :
|
||||||
base (Path.Combine (SSHPath, command), args)
|
base (Path.Combine (SSHPath, command), args)
|
||||||
{
|
{
|
||||||
string GIT_SSH_COMMAND = SSHPath;
|
|
||||||
|
|
||||||
if (auth_info != null)
|
|
||||||
GIT_SSH_COMMAND = FormatGitSSHCommand (auth_info);
|
|
||||||
|
|
||||||
SetEnvironmentVariable ("GIT_SSH_COMMAND", GIT_SSH_COMMAND);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static string FormatGitSSHCommand (SSHAuthenticationInfo auth_info)
|
|
||||||
{
|
|
||||||
return SSHCommandPath + " " +
|
|
||||||
"-i " + auth_info.PrivateKeyFilePath.Replace ("\\" , "/").Replace (" ", "\\ ") + " " +
|
|
||||||
"-o UserKnownHostsFile=" + auth_info.KnownHostsFilePath.Replace ("\\", "/").Replace (" ", "\\ ") + " " +
|
|
||||||
"-o IdentitiesOnly=yes" + " " + // Don't fall back to other keys on the system
|
|
||||||
"-o PasswordAuthentication=no" + " " + // Don't hang on possible password prompts
|
|
||||||
"-F /dev/null"; // Ignore the system's SSH config file
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue