[paths] change the way git lookup is done

This commit is contained in:
Hylke Bons 2011-03-23 23:14:44 +00:00
parent 6bf6de5cc2
commit b2253a06ff

View file

@ -29,53 +29,26 @@ namespace SparkleLib {
get { get {
// QUICK RC1 HACK FIX string [] possible_git_paths = {"/usr/bin/git",
if (File.Exists ("/usr/local/git/bin/git")) "/usr/local/git/bin/git",
return "/usr/local/git/bin/git"; "/usr/local/bin/git"};
else if (File.Exists ("/usr/bin/git"))
return "/usr/bin/git";
Process process = new Process (); foreach (string git_path in possible_git_paths)
process.StartInfo.RedirectStandardOutput = true; if (File.Exists (git_path))
process.StartInfo.UseShellExecute = false; return git_path;
process.StartInfo.FileName = "which";
process.StartInfo.Arguments = Backend.Name.ToLower ();
process.Start ();
string path = process.StandardOutput.ReadToEnd ();
path = path.Trim ();
if (!string.IsNullOrEmpty (path)) {
return path;
} else {
Console.WriteLine ("Sorry, SparkleShare needs " + Backend.Name + " to run, but it wasn't found.");
return null; return null;
} }
} }
}
public static bool IsPresent { public static bool IsPresent {
get { get {
Process process = new Process (); return (Path != null);
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.UseShellExecute = false;
process.StartInfo.FileName = "which";
process.StartInfo.Arguments = Backend.Name.ToLower ();
process.Start ();
string path = process.StandardOutput.ReadToEnd ();
path = path.Trim ();
return !string.IsNullOrEmpty (path);
} }