From 6e16361c8fec2e3f592f7798dbcbfbb942bc0943 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Sun, 29 May 2016 20:12:20 -0700 Subject: [PATCH] List GitLFS version --- SparkleShare/Common/BaseController.cs | 4 ++- Sparkles/Git/GitCommand.cs | 45 ++++++++++++++++++++++----- 2 files changed, 41 insertions(+), 8 deletions(-) diff --git a/SparkleShare/Common/BaseController.cs b/SparkleShare/Common/BaseController.cs index 7b03ee11..66badd61 100644 --- a/SparkleShare/Common/BaseController.cs +++ b/SparkleShare/Common/BaseController.cs @@ -215,9 +215,11 @@ namespace SparkleShare { public virtual void Initialize () { Logger.LogInfo ("Environment", "SparkleShare " + InstallationInfo.Version); + Logger.LogInfo ("Environment", "Git LFS " + Sparkles.Git.GitCommand.GitLFSVersion); Logger.LogInfo ("Environment", "Git " + Sparkles.Git.GitCommand.GitVersion); + + // TODO: ToString() with nice os version names (Mac OS X Yosemite, Fedora 24, Ubuntu 16.04, etc.) Logger.LogInfo ("Environment", InstallationInfo.OperatingSystem + " (" + Environment.OSVersion + ")"); - // todo tostring with nice os version names Preset.PresetsPath = PresetsPath; InstallProtocolHandler (); diff --git a/Sparkles/Git/GitCommand.cs b/Sparkles/Git/GitCommand.cs index 90cdfe73..172c01b3 100644 --- a/Sparkles/Git/GitCommand.cs +++ b/Sparkles/Git/GitCommand.cs @@ -25,6 +25,7 @@ namespace Sparkles.Git { static string git_path; + static string git_lfs_path; public static string GitPath { get { @@ -39,6 +40,19 @@ namespace Sparkles.Git { } } + public static string GitLFSPath { + get { + if (git_lfs_path == null) + git_lfs_path = LocateCommand ("git-lfs"); + + return git_lfs_path; + } + + set { + git_lfs_path = value; + } + } + public static string GitVersion { get { @@ -50,6 +64,16 @@ namespace Sparkles.Git { } } + public static string GitLFSVersion { + get { + if (GitLFSPath == null) + GitLFSPath = LocateCommand ("git-lfs"); + + string git_lfs_version = new Command (GitLFSPath, "version").StartAndReadStandardOutput (); + return git_lfs_version.Replace ("git-lfs/", "").Split (' ') [0]; + } + } + public GitCommand (string working_dir, string args) : this (working_dir, args, null) { @@ -65,23 +89,30 @@ namespace Sparkles.Git { string GIT_SSH_COMMAND = SSHPath; - if (auth_info != null) { - GIT_SSH_COMMAND = SSHPath + " " + - "-i \"" + auth_info.PrivateKeyFilePath + "\" " + - "-o UserKnownHostsFile=\"" + auth_info.KnownHostsFilePath + "\" " + - "-o PasswordAuthentication=no " + - "-F /dev/null"; // Ignore the environment's SSH config file - } + if (auth_info != null) + GIT_SSH_COMMAND = FormatGitSSHCommand (auth_info); if (ExecPath == null) SetEnvironmentVariable ("GIT_EXEC_PATH", ExecPath); + Console.WriteLine (GIT_SSH_COMMAND); + SetEnvironmentVariable ("GIT_SSH_COMMAND", GIT_SSH_COMMAND); SetEnvironmentVariable ("GIT_TERMINAL_PROMPT", "0"); SetEnvironmentVariable ("LANG", "en_US"); } + public static string FormatGitSSHCommand (SSHAuthenticationInfo auth_info) + { + return SSHPath + " " + + "-i " + auth_info.PrivateKeyFilePath.Replace (" ", "\\ ") + " " + + "-o UserKnownHostsFile=" + auth_info.KnownHostsFilePath.Replace (" ", "\\ ") + " " + + "-o PasswordAuthentication=no " + + "-F /dev/null"; // Ignore the environment's SSH config file + } + + void SetEnvironmentVariable (string variable, string content) { if (StartInfo.EnvironmentVariables.ContainsKey (variable))