[paths] Add a SparklePath for git
This commit is contained in:
parent
b5777a2e51
commit
b90a2c8f77
|
@ -35,7 +35,6 @@ namespace SparkleLib {
|
||||||
|
|
||||||
private string TargetFolder;
|
private string TargetFolder;
|
||||||
private string RemoteOriginUrl;
|
private string RemoteOriginUrl;
|
||||||
public SparkleProgress Progress;
|
|
||||||
|
|
||||||
|
|
||||||
public SparkleFetcher (string url, string folder)
|
public SparkleFetcher (string url, string folder)
|
||||||
|
@ -43,7 +42,6 @@ namespace SparkleLib {
|
||||||
|
|
||||||
TargetFolder = folder;
|
TargetFolder = folder;
|
||||||
RemoteOriginUrl = url;
|
RemoteOriginUrl = url;
|
||||||
Progress = new SparkleProgress ();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,25 +65,10 @@ namespace SparkleLib {
|
||||||
process.StartInfo.RedirectStandardOutput = true;
|
process.StartInfo.RedirectStandardOutput = true;
|
||||||
process.StartInfo.RedirectStandardError = true;
|
process.StartInfo.RedirectStandardError = true;
|
||||||
process.StartInfo.UseShellExecute = false;
|
process.StartInfo.UseShellExecute = false;
|
||||||
process.StartInfo.FileName = "git";
|
process.StartInfo.FileName = SparklePaths.GitPath;
|
||||||
process.StartInfo.Arguments = "clone --progress " +
|
process.StartInfo.Arguments = "clone --progress " +
|
||||||
"\"" + RemoteOriginUrl + "\" " + "\"" + TargetFolder + "\"";
|
"\"" + RemoteOriginUrl + "\" " + "\"" + TargetFolder + "\"";
|
||||||
|
|
||||||
Timer timer = new Timer () {
|
|
||||||
Interval = 1000
|
|
||||||
};
|
|
||||||
timer.Elapsed += delegate {
|
|
||||||
Console.WriteLine ("ppppppppppppppp");
|
|
||||||
Console.WriteLine (process.StandardError.ReadToEnd ());
|
|
||||||
|
|
||||||
};
|
|
||||||
process.ErrorDataReceived += delegate (object o, DataReceivedEventArgs args) {
|
|
||||||
Console.WriteLine (">>>>>>>>>" + args.Data);
|
|
||||||
Progress.Speed = "";
|
|
||||||
Progress.Fraction = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
process.Exited += delegate {
|
process.Exited += delegate {
|
||||||
|
|
||||||
SparkleHelpers.DebugInfo ("Git", "Exit code " + process.ExitCode.ToString ());
|
SparkleHelpers.DebugInfo ("Git", "Exit code " + process.ExitCode.ToString ());
|
||||||
|
@ -110,7 +93,7 @@ Console.WriteLine ("ppppppppppppppp");
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
timer.Start();
|
|
||||||
process.Start ();
|
process.Start ();
|
||||||
process.BeginErrorReadLine ();
|
process.BeginErrorReadLine ();
|
||||||
|
|
||||||
|
@ -165,66 +148,5 @@ timer.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public class SparkleProgress {
|
|
||||||
|
|
||||||
public string _Speed;
|
|
||||||
public int _Fraction;
|
|
||||||
|
|
||||||
public delegate void ProgressChangedEventHandler ();
|
|
||||||
public event ProgressChangedEventHandler ProgressChanged;
|
|
||||||
|
|
||||||
|
|
||||||
public SparkleProgress ()
|
|
||||||
{
|
|
||||||
|
|
||||||
_Speed = "0 B/s";
|
|
||||||
_Fraction = 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public string Speed
|
|
||||||
{
|
|
||||||
|
|
||||||
get {
|
|
||||||
|
|
||||||
return _Speed;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
set {
|
|
||||||
|
|
||||||
_Speed = value;
|
|
||||||
|
|
||||||
if (ProgressChanged != null)
|
|
||||||
ProgressChanged ();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Fraction
|
|
||||||
{
|
|
||||||
|
|
||||||
get {
|
|
||||||
|
|
||||||
return _Fraction;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
set {
|
|
||||||
|
|
||||||
_Fraction = value;
|
|
||||||
|
|
||||||
if (ProgressChanged != null)
|
|
||||||
ProgressChanged ();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Mono.Unix;
|
using Mono.Unix;
|
||||||
|
|
||||||
|
@ -22,10 +23,10 @@ namespace SparkleLib {
|
||||||
|
|
||||||
public static class SparklePaths
|
public static class SparklePaths
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public static string GitPath = GetGitPath ();
|
||||||
|
|
||||||
private static UnixUserInfo UnixUserInfo = new UnixUserInfo (UnixEnvironment.UserName);
|
public static string HomePath = new UnixUserInfo (UnixEnvironment.UserName).HomeDirectory;
|
||||||
|
|
||||||
public static string HomePath = UnixUserInfo.HomeDirectory;
|
|
||||||
|
|
||||||
public static string SparklePath = Path.Combine (HomePath ,"SparkleShare");
|
public static string SparklePath = Path.Combine (HomePath ,"SparkleShare");
|
||||||
|
|
||||||
|
@ -42,6 +43,27 @@ namespace SparkleLib {
|
||||||
public static string SparkleIconPath = SparkleHelpers.CombineMore (Defines.PREFIX, "share", "sparkleshare",
|
public static string SparkleIconPath = SparkleHelpers.CombineMore (Defines.PREFIX, "share", "sparkleshare",
|
||||||
"icons");
|
"icons");
|
||||||
|
|
||||||
|
|
||||||
|
private static string GetGitPath ()
|
||||||
|
{
|
||||||
|
|
||||||
|
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 ();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty (git_path))
|
||||||
|
return git_path;
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -258,7 +258,7 @@ namespace SparkleLib {
|
||||||
EnableRaisingEvents = true
|
EnableRaisingEvents = true
|
||||||
};
|
};
|
||||||
|
|
||||||
Process.StartInfo.FileName = "/opt/local/bin/git";
|
Process.StartInfo.FileName = SparklePaths.GitPath;
|
||||||
Process.StartInfo.RedirectStandardOutput = true;
|
Process.StartInfo.RedirectStandardOutput = true;
|
||||||
Process.StartInfo.UseShellExecute = false;
|
Process.StartInfo.UseShellExecute = false;
|
||||||
Process.StartInfo.WorkingDirectory = LocalPath;
|
Process.StartInfo.WorkingDirectory = LocalPath;
|
||||||
|
@ -430,7 +430,7 @@ namespace SparkleLib {
|
||||||
EnableRaisingEvents = true
|
EnableRaisingEvents = true
|
||||||
};
|
};
|
||||||
|
|
||||||
process.StartInfo.FileName = "/opt/local/bin/git";
|
process.StartInfo.FileName = SparklePaths.GitPath;
|
||||||
process.StartInfo.RedirectStandardOutput = true;
|
process.StartInfo.RedirectStandardOutput = true;
|
||||||
process.StartInfo.UseShellExecute = false;
|
process.StartInfo.UseShellExecute = false;
|
||||||
process.StartInfo.WorkingDirectory = LocalPath;
|
process.StartInfo.WorkingDirectory = LocalPath;
|
||||||
|
@ -663,7 +663,7 @@ namespace SparkleLib {
|
||||||
EnableRaisingEvents = true
|
EnableRaisingEvents = true
|
||||||
};
|
};
|
||||||
|
|
||||||
process.StartInfo.FileName = "/opt/local/bin/git";
|
process.StartInfo.FileName = SparklePaths.GitPath;
|
||||||
process.StartInfo.RedirectStandardOutput = true;
|
process.StartInfo.RedirectStandardOutput = true;
|
||||||
process.StartInfo.UseShellExecute = false;
|
process.StartInfo.UseShellExecute = false;
|
||||||
process.StartInfo.WorkingDirectory = LocalPath;
|
process.StartInfo.WorkingDirectory = LocalPath;
|
||||||
|
@ -831,9 +831,9 @@ namespace SparkleLib {
|
||||||
|
|
||||||
Process.StartInfo.Arguments = "push origin master";
|
Process.StartInfo.Arguments = "push origin master";
|
||||||
|
|
||||||
Process.Start ();
|
|
||||||
Process.WaitForExit ();
|
Process.WaitForExit ();
|
||||||
|
Process.Start ();
|
||||||
|
|
||||||
Process.Exited += delegate {
|
Process.Exited += delegate {
|
||||||
|
|
||||||
_IsSyncing = false;
|
_IsSyncing = false;
|
||||||
|
|
|
@ -275,6 +275,9 @@ namespace SparkleShare {
|
||||||
// Creates the SparkleShare folder in the user's home folder
|
// Creates the SparkleShare folder in the user's home folder
|
||||||
public abstract bool CreateSparkleShareFolder ();
|
public abstract bool CreateSparkleShareFolder ();
|
||||||
|
|
||||||
|
// Opens the SparkleShare folder or an (optional) subfolder
|
||||||
|
public abstract void OpenSparkleShareFolder (string subfolder);
|
||||||
|
|
||||||
|
|
||||||
// Fires events for the current syncing state
|
// Fires events for the current syncing state
|
||||||
private void UpdateState ()
|
private void UpdateState ()
|
||||||
|
@ -523,7 +526,6 @@ namespace SparkleShare {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void OpenSparkleShareFolder (string subfolder);
|
|
||||||
|
|
||||||
// Adds the user's SparkleShare key to the ssh-agent,
|
// Adds the user's SparkleShare key to the ssh-agent,
|
||||||
// so all activity is done with this key
|
// so all activity is done with this key
|
||||||
|
|
Loading…
Reference in a new issue