[paths] look for git using whereis
This commit is contained in:
parent
d7c49da1e6
commit
ad2c87356f
|
@ -24,7 +24,7 @@ namespace SparkleLib {
|
||||||
public static class SparklePaths
|
public static class SparklePaths
|
||||||
{
|
{
|
||||||
|
|
||||||
public static string GitPath = "/usr/bin/git"; // TODO: Don't hardcode this
|
public static string GitPath = SystemGitPath;
|
||||||
|
|
||||||
public static string HomePath = new UnixUserInfo (UnixEnvironment.UserName).HomeDirectory;
|
public static string HomePath = new UnixUserInfo (UnixEnvironment.UserName).HomeDirectory;
|
||||||
|
|
||||||
|
@ -44,23 +44,36 @@ namespace SparkleLib {
|
||||||
"icons");
|
"icons");
|
||||||
|
|
||||||
|
|
||||||
private static string GetGitPath ()
|
private static string SystemGitPath
|
||||||
{
|
{
|
||||||
|
|
||||||
Process process = new Process ();
|
get {
|
||||||
|
|
||||||
process.StartInfo.RedirectStandardOutput = true;
|
Process process = new Process ();
|
||||||
process.StartInfo.UseShellExecute = false;
|
|
||||||
process.StartInfo.FileName = "which";
|
|
||||||
process.StartInfo.Arguments = "git";
|
|
||||||
process.Start ();
|
|
||||||
|
|
||||||
string git_path = process.StandardOutput.ReadToEnd ().Trim ();
|
process.StartInfo.RedirectStandardOutput = true;
|
||||||
|
process.StartInfo.UseShellExecute = false;
|
||||||
|
process.StartInfo.FileName = "which";
|
||||||
|
process.StartInfo.Arguments = "git";
|
||||||
|
process.Start ();
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty (git_path))
|
string git_path = process.StandardOutput.ReadToEnd ();
|
||||||
return git_path;
|
git_path = git_path.Trim ();
|
||||||
else
|
|
||||||
return null;
|
if (!string.IsNullOrEmpty (git_path)) {
|
||||||
|
|
||||||
|
return git_path;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
Console.WriteLine ("Sorry, SparkleShare needs Git to run, but it wasn't found.");
|
||||||
|
Environment.Exit (-1);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue