Remove SparkleBackend crap

This commit is contained in:
Hylke Bons 2012-02-06 14:40:48 +01:00
parent 121bb3e320
commit e50ad79f92
4 changed files with 39 additions and 88 deletions

View file

@ -16,6 +16,7 @@
using System;
using System.IO;
using System.Diagnostics;
namespace SparkleLib {
@ -23,27 +24,57 @@ namespace SparkleLib {
public class SparkleGit : Process {
public static string ExecPath = null;
public static string Path = null;
public SparkleGit (string path, string args) : base ()
{
Path = LocateGit ();
EnableRaisingEvents = true;
StartInfo.FileName = SparkleBackend.DefaultBackend.Path;
StartInfo.FileName = Path;
StartInfo.RedirectStandardOutput = true;
StartInfo.UseShellExecute = false;
StartInfo.WorkingDirectory = path;
if (!string.IsNullOrEmpty (ExecPath))
StartInfo.Arguments = "--exec-path=\"" + ExecPath + "\" " + args;
else
if (string.IsNullOrEmpty (ExecPath))
StartInfo.Arguments = args;
else
StartInfo.Arguments = "--exec-path=\"" + ExecPath + "\" " + args;
}
new public void Start ()
{
SparkleHelpers.DebugInfo ("Cmd", "git " + StartInfo.Arguments);
base.Start ();
try {
base.Start ();
} catch (Exception e) {
SparkleHelpers.DebugInfo ("Cmd", "There's a problem running Git: " + e.Message);
Environment.Exit (-1);
}
}
private string LocateGit ()
{
if (!string.IsNullOrEmpty (Path))
return Path;
string [] possible_git_paths = new string [] {
"/usr/bin/git",
"/usr/local/bin/git",
"/opt/local/bin/git",
"/usr/local/git/bin/git"
};
foreach (string path in possible_git_paths)
if (File.Exists (path))
return path;
return "git";
}
}
}

View file

@ -21,40 +21,7 @@ using System.Runtime.InteropServices;
namespace SparkleLib {
public class SparkleBackend {
public static SparkleBackend DefaultBackend = new SparkleBackendGit ();
public string Name;
public string Path;
public SparkleBackend (string name, string [] paths)
{
Name = name;
Path = "git";
foreach (string path in paths) {
if (File.Exists (path)) {
Path = path;
break;
}
}
}
public bool IsPresent {
get {
return (Path != null);
}
}
public bool IsUsablePath (string path)
{
return (path.Length > 0);
}
public static class SparkleBackend {
public static string Version {
get {
@ -65,7 +32,7 @@ namespace SparkleLib {
// Strange magic needed by Platform ()
[DllImport ("libc")]
static extern int uname (IntPtr buf);
private static extern int uname (IntPtr buf);
// This fixes the PlatformID enumeration for MacOSX in Environment.OSVersion.Platform,
@ -90,44 +57,4 @@ namespace SparkleLib {
}
}
}
public class SparkleBackendGit : SparkleBackend {
private static string name = "Git";
private static string [] paths = new string [] {
"/opt/local/bin/git",
"/usr/bin/git",
"/usr/local/bin/git",
"/usr/local/git/bin/git"
};
public SparkleBackendGit () : base (name, paths) { }
}
public class SparkleBackendHg : SparkleBackend {
private static string name = "Hg";
private static string [] paths = new string [] {
"/opt/local/bin/hg",
"/usr/bin/hg"
};
public SparkleBackendHg () : base (name, paths) { }
}
public class SparkleBackendScp : SparkleBackend {
private static string name = "Scp";
private static string [] paths = new string [] {
"/usr/bin/scp"
};
public SparkleBackendScp () : base (name, paths) { }
}
}

View file

@ -54,7 +54,7 @@ namespace SparkleShare {
// Let's use the bundled git first
SparkleBackend.DefaultBackend.Path =
SparkleGit.Path =
Path.Combine (NSBundle.MainBundle.ResourcePath,
"git", "libexec", "git-core", "git");

View file

@ -782,13 +782,6 @@ namespace SparkleShare {
}
public bool BackendIsPresent {
get {
return SparkleBackend.DefaultBackend.IsPresent;
}
}
// Looks up the user's name from the global configuration
public string UserName
{