Skip to content

Commit

Permalink
[paths] look for git using whereis
Browse files Browse the repository at this point in the history
  • Loading branch information
hbons committed Feb 22, 2011
1 parent d7c49da commit ad2c873
Showing 1 changed file with 29 additions and 16 deletions.
45 changes: 29 additions & 16 deletions SparkleLib/SparklePaths.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace SparkleLib {
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;

Expand All @@ -44,24 +44,37 @@ public static class SparklePaths
"icons");


private static string GetGitPath ()
private static string SystemGitPath
{

Process process = new Process ();

process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.UseShellExecute = false;
process.StartInfo.FileName = "which";
process.StartInfo.Arguments = "git";
process.Start ();

string git_path = process.StandardOutput.ReadToEnd ().Trim ();
get {

if (!string.IsNullOrEmpty (git_path))
return git_path;
else
return null;

Process process = new Process ();

process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.UseShellExecute = false;
process.StartInfo.FileName = "which";
process.StartInfo.Arguments = "git";
process.Start ();

string git_path = process.StandardOutput.ReadToEnd ();
git_path = git_path.Trim ();

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;

}

}

}

}
Expand Down

0 comments on commit ad2c873

Please sign in to comment.