Add new fetcher class
This commit is contained in:
parent
4ebba45193
commit
ae96a5c3f8
|
@ -10,6 +10,7 @@ LINK = $(REF_SPARKLESHARE)
|
||||||
SOURCES = \
|
SOURCES = \
|
||||||
Defines.cs \
|
Defines.cs \
|
||||||
SparkleBubble.cs \
|
SparkleBubble.cs \
|
||||||
|
SparkleFetcher.cs \
|
||||||
SparkleHelpers.cs \
|
SparkleHelpers.cs \
|
||||||
SparkleIntro.cs \
|
SparkleIntro.cs \
|
||||||
SparklePaths.cs \
|
SparklePaths.cs \
|
||||||
|
|
122
SparkleShare/SparkleFetcher.cs
Normal file
122
SparkleShare/SparkleFetcher.cs
Normal file
|
@ -0,0 +1,122 @@
|
||||||
|
// SparkleShare, an instant update workflow to Git.
|
||||||
|
// Copyright (C) 2010 Hylke Bons <hylkebons@gmail.com>
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
using Gtk;
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace SparkleShare {
|
||||||
|
|
||||||
|
public class SparkleFetcher {
|
||||||
|
|
||||||
|
public delegate void CloningStartedEventHandler (object o, SparkleEventArgs args);
|
||||||
|
public delegate void CloningFinishedEventHandler (object o, SparkleEventArgs args);
|
||||||
|
public delegate void CloningFailedEventHandler (object o, SparkleEventArgs args);
|
||||||
|
|
||||||
|
public event CloningStartedEventHandler CloningStarted;
|
||||||
|
public event CloningFinishedEventHandler CloningFinished;
|
||||||
|
public event CloningFailedEventHandler CloningFailed;
|
||||||
|
|
||||||
|
private string Folder;
|
||||||
|
private string RemoteOriginUrl;
|
||||||
|
private string RepoName;
|
||||||
|
|
||||||
|
|
||||||
|
public SparkleFetcher (string url, string folder)
|
||||||
|
{
|
||||||
|
|
||||||
|
RepoName = Path.GetDirectoryName (folder);
|
||||||
|
Folder = folder;
|
||||||
|
RemoteOriginUrl = url;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void Clone ()
|
||||||
|
{
|
||||||
|
|
||||||
|
SparkleEventArgs args = new SparkleEventArgs ("CloningStarted");
|
||||||
|
|
||||||
|
if (CloningStarted != null)
|
||||||
|
CloningStarted (this, args);
|
||||||
|
|
||||||
|
Process process = new Process () {
|
||||||
|
EnableRaisingEvents = true
|
||||||
|
};
|
||||||
|
|
||||||
|
process.StartInfo.RedirectStandardOutput = true;
|
||||||
|
process.StartInfo.UseShellExecute = false;
|
||||||
|
process.StartInfo.FileName = "git";
|
||||||
|
process.StartInfo.Arguments = "clone " + RemoteOriginUrl + " " + Folder;
|
||||||
|
|
||||||
|
Console.WriteLine (Folder);
|
||||||
|
|
||||||
|
Console.WriteLine (process.StartInfo.FileName + " " + process.StartInfo.Arguments);
|
||||||
|
|
||||||
|
process.Exited += delegate {
|
||||||
|
|
||||||
|
Console.WriteLine (process.ExitTime.ToString ());
|
||||||
|
Console.WriteLine (process.ExitCode);
|
||||||
|
|
||||||
|
if (process.ExitCode != 0) {
|
||||||
|
|
||||||
|
args = new SparkleEventArgs ("CloningFailed");
|
||||||
|
|
||||||
|
if (CloningFailed != null)
|
||||||
|
CloningFailed (this, args);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
InstallExcludeRules ();
|
||||||
|
|
||||||
|
args = new SparkleEventArgs ("CloningFinished");
|
||||||
|
|
||||||
|
Console.WriteLine ("FINISHED");
|
||||||
|
|
||||||
|
if (CloningFinished != null) {
|
||||||
|
Console.WriteLine ("EVENT FIRED");
|
||||||
|
CloningFinished (this, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
process.Start ();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Add a .gitignore file to the repo
|
||||||
|
private void InstallExcludeRules ()
|
||||||
|
{
|
||||||
|
|
||||||
|
TextWriter writer;
|
||||||
|
writer = new StreamWriter (SparkleHelpers.CombineMore (SparklePaths.SparklePath,
|
||||||
|
RepoName, ".git/info/exclude"));
|
||||||
|
|
||||||
|
writer.WriteLine ("*~"); // Ignore gedit swap files
|
||||||
|
writer.WriteLine (".*.sw?"); // Ignore vi swap files
|
||||||
|
writer.WriteLine (".DS_store"); // Ignore OSX's invisible directories
|
||||||
|
|
||||||
|
writer.Close ();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -74,7 +74,7 @@ namespace SparkleShare {
|
||||||
BorderWidth = 30
|
BorderWidth = 30
|
||||||
};
|
};
|
||||||
|
|
||||||
Label introduction = new Label ("<span size='x-large'><b>" +
|
Label header = new Label ("<span size='x-large'><b>" +
|
||||||
_("Welcome to SparkleShare!") +
|
_("Welcome to SparkleShare!") +
|
||||||
"</b></span>") {
|
"</b></span>") {
|
||||||
UseMarkup = true,
|
UseMarkup = true,
|
||||||
|
@ -146,7 +146,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
controls.Add (NextButton);
|
controls.Add (NextButton);
|
||||||
|
|
||||||
layout_vertical.PackStart (introduction, false, false, 0);
|
layout_vertical.PackStart (header, false, false, 0);
|
||||||
layout_vertical.PackStart (information, false, false, 21);
|
layout_vertical.PackStart (information, false, false, 21);
|
||||||
layout_vertical.PackStart (new Label (""), false, false, 0);
|
layout_vertical.PackStart (new Label (""), false, false, 0);
|
||||||
layout_vertical.PackStart (table, false, false, 0);
|
layout_vertical.PackStart (table, false, false, 0);
|
||||||
|
@ -176,6 +176,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void ShowStepTwo ()
|
public void ShowStepTwo ()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -194,7 +195,7 @@ namespace SparkleShare {
|
||||||
BorderWidth = 30
|
BorderWidth = 30
|
||||||
};
|
};
|
||||||
|
|
||||||
Label introduction = new Label ("<span size='x-large'><b>" +
|
Label header = new Label ("<span size='x-large'><b>" +
|
||||||
_("Where does your remote folder reside?") +
|
_("Where does your remote folder reside?") +
|
||||||
"</b></span>") {
|
"</b></span>") {
|
||||||
UseMarkup = true,
|
UseMarkup = true,
|
||||||
|
@ -223,13 +224,13 @@ namespace SparkleShare {
|
||||||
"</span>";
|
"</span>";
|
||||||
|
|
||||||
RadioButton radio_button_github = new RadioButton (radio_button, github_text);
|
RadioButton radio_button_github = new RadioButton (radio_button, github_text);
|
||||||
|
|
||||||
(radio_button_github.Child as Label).UseMarkup = true;
|
(radio_button_github.Child as Label).UseMarkup = true;
|
||||||
(radio_button_github.Child as Label).Wrap = true;
|
(radio_button_github.Child as Label).Wrap = true;
|
||||||
|
|
||||||
string gnome_text = "<b>" + _("The GNOME Project") + "</b>\n" +
|
string gnome_text = "<b>" + _("The GNOME Project") + "</b>\n" +
|
||||||
"<span fgcolor='#777' size='small'>" +
|
"<span fgcolor='#777' size='small'>" +
|
||||||
_("GNOME is an easy to understand interface to your computer.") +
|
_("GNOME is an easy to understand interface to your computer.") + " " +
|
||||||
_("Select this option if you’re a developer or designer working on GNOME.") +
|
_("Select this option if you’re a developer or designer working on GNOME.") +
|
||||||
"</span>";
|
"</span>";
|
||||||
|
|
||||||
|
@ -245,7 +246,7 @@ namespace SparkleShare {
|
||||||
"</span>";
|
"</span>";
|
||||||
|
|
||||||
RadioButton radio_button_gitorious = new RadioButton (radio_button, gitorious_text) {
|
RadioButton radio_button_gitorious = new RadioButton (radio_button, gitorious_text) {
|
||||||
Xalign = 0
|
Xalign = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
(radio_button_gitorious.Child as Label).UseMarkup = true;
|
(radio_button_gitorious.Child as Label).UseMarkup = true;
|
||||||
|
@ -292,7 +293,7 @@ namespace SparkleShare {
|
||||||
layout_folder.PackStart (folder_label, true, true, 12);
|
layout_folder.PackStart (folder_label, true, true, 12);
|
||||||
layout_folder.PackStart (FolderEntry, true, true, 0);
|
layout_folder.PackStart (FolderEntry, true, true, 0);
|
||||||
|
|
||||||
|
|
||||||
HButtonBox controls = new HButtonBox () {
|
HButtonBox controls = new HButtonBox () {
|
||||||
BorderWidth = 12,
|
BorderWidth = 12,
|
||||||
Layout = ButtonBoxStyle.End,
|
Layout = ButtonBoxStyle.End,
|
||||||
|
@ -303,9 +304,87 @@ namespace SparkleShare {
|
||||||
|
|
||||||
AddButton.Clicked += delegate {
|
AddButton.Clicked += delegate {
|
||||||
|
|
||||||
ShowStepTwoAndAHalf ();
|
string server = "";
|
||||||
|
|
||||||
// TODO
|
if (radio_button.Active) {
|
||||||
|
|
||||||
|
server = ServerEntry.Text;
|
||||||
|
|
||||||
|
// Remove the trailing slash if there is one
|
||||||
|
if (server.EndsWith ("/"))
|
||||||
|
server = server.Trim ("/".ToCharArray ());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (radio_button_gitorious.Active)
|
||||||
|
server = "ssh://git@gitorious.org";
|
||||||
|
|
||||||
|
if (radio_button_github.Active)
|
||||||
|
server = "ssh://git@github.com";
|
||||||
|
|
||||||
|
if (radio_button_gnome.Active)
|
||||||
|
server = "ssh://git@gnome.org";
|
||||||
|
|
||||||
|
|
||||||
|
string name = FolderEntry.Text;
|
||||||
|
|
||||||
|
// Remove the starting slash if there is one
|
||||||
|
if (name.StartsWith ("/"))
|
||||||
|
name = name.Substring (1);
|
||||||
|
|
||||||
|
|
||||||
|
string url = server + "/" + name;
|
||||||
|
string tmp_folder = SparkleHelpers.CombineMore (SparklePaths.SparkleTmpPath, name);
|
||||||
|
|
||||||
|
SparkleFetcher fetcher = new SparkleFetcher (url, tmp_folder);
|
||||||
|
|
||||||
|
Console.WriteLine (url);
|
||||||
|
|
||||||
|
fetcher.CloningStarted += delegate {
|
||||||
|
|
||||||
|
SparkleHelpers.DebugInfo ("Git", "[" + name + "] Cloning Repository");
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
fetcher.CloningFinished += delegate {
|
||||||
|
|
||||||
|
Console.WriteLine ("CLONING FINISHED");
|
||||||
|
|
||||||
|
SparkleHelpers.DebugInfo ("Git", "[" + name + "] Repository cloned");
|
||||||
|
|
||||||
|
Directory.Move (tmp_folder,
|
||||||
|
SparkleHelpers.CombineMore (SparklePaths.SparklePath, name));
|
||||||
|
|
||||||
|
// Install username and email from global file
|
||||||
|
|
||||||
|
ShowFinishedStep ();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
fetcher.CloningFailed += delegate {
|
||||||
|
|
||||||
|
SparkleHelpers.DebugInfo ("Git", "[" + name + "] Cloning failed");
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
Directory.Delete (SparkleHelpers.CombineMore (SparklePaths.SparkleTmpPath,
|
||||||
|
name));
|
||||||
|
|
||||||
|
SparkleHelpers.DebugInfo ("Config",
|
||||||
|
"[" + name + "] Deleted temporary directory");
|
||||||
|
|
||||||
|
} catch (System.IO.DirectoryNotFoundException) {
|
||||||
|
|
||||||
|
ShowErrorStep ();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
ShowStepTwoAndAHalf ();
|
||||||
|
fetcher.Clone ();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -315,12 +394,13 @@ namespace SparkleShare {
|
||||||
ShowStepThree ();
|
ShowStepThree ();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
if (!StepTwoOnly)
|
if (!StepTwoOnly)
|
||||||
controls.Add (skip_button);
|
controls.Add (skip_button);
|
||||||
|
|
||||||
controls.Add (AddButton);
|
controls.Add (AddButton);
|
||||||
|
|
||||||
layout_vertical.PackStart (introduction, false, false, 0);
|
layout_vertical.PackStart (header, false, false, 0);
|
||||||
layout_vertical.PackStart (new Label (""), false, false, 3);
|
layout_vertical.PackStart (new Label (""), false, false, 3);
|
||||||
layout_vertical.PackStart (table, false, false, 0);
|
layout_vertical.PackStart (table, false, false, 0);
|
||||||
layout_vertical.PackStart (layout_folder, false, false, 6);
|
layout_vertical.PackStart (layout_folder, false, false, 6);
|
||||||
|
@ -340,6 +420,133 @@ namespace SparkleShare {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void ShowErrorStep ()
|
||||||
|
{
|
||||||
|
|
||||||
|
Remove (Child);
|
||||||
|
|
||||||
|
Title = _("Error adding folder");
|
||||||
|
|
||||||
|
HBox layout_horizontal = new HBox (false, 6);
|
||||||
|
|
||||||
|
Image side_splash = new Image (SparkleHelpers.CombineMore (Defines.PREFIX, "share", "pixmaps",
|
||||||
|
"side-splash.png"));
|
||||||
|
|
||||||
|
VBox wrapper = new VBox (false, 0);
|
||||||
|
|
||||||
|
VBox layout_vertical = new VBox (false, 0) {
|
||||||
|
BorderWidth = 30
|
||||||
|
};
|
||||||
|
|
||||||
|
Label header = new Label ("<span size='x-large'><b>" +
|
||||||
|
_("Something went wrong…") +
|
||||||
|
"</b></span>") {
|
||||||
|
UseMarkup = true,
|
||||||
|
Xalign = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
Label information = new Label (_("Hey, it's an Alpha!")) {
|
||||||
|
Xalign = 0,
|
||||||
|
Wrap = true
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
HButtonBox controls = new HButtonBox () {
|
||||||
|
BorderWidth = 12,
|
||||||
|
Layout = ButtonBoxStyle.End
|
||||||
|
};
|
||||||
|
|
||||||
|
Button try_again_button = new Button (_("Try again…")) {
|
||||||
|
Sensitive = true
|
||||||
|
};
|
||||||
|
|
||||||
|
try_again_button.Clicked += delegate (object o, EventArgs args) {
|
||||||
|
|
||||||
|
ShowStepTwo ();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
controls.Add (try_again_button);
|
||||||
|
|
||||||
|
layout_vertical.PackStart (header, false, false, 0);
|
||||||
|
layout_vertical.PackStart (information, false, false, 0);
|
||||||
|
|
||||||
|
wrapper.PackStart (layout_vertical, true, true, 0);
|
||||||
|
wrapper.PackStart (controls, false, true, 0);
|
||||||
|
|
||||||
|
layout_horizontal.PackStart (side_splash, false, false, 0);
|
||||||
|
layout_horizontal.PackStart (wrapper, true, true, 0);
|
||||||
|
|
||||||
|
Add (layout_horizontal);
|
||||||
|
|
||||||
|
ShowAll ();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void ShowFinishedStep ()
|
||||||
|
{
|
||||||
|
|
||||||
|
Remove (Child);
|
||||||
|
|
||||||
|
Title = _("Folder Added Successfully");
|
||||||
|
|
||||||
|
HBox layout_horizontal = new HBox (false, 6);
|
||||||
|
|
||||||
|
Image side_splash = new Image (SparkleHelpers.CombineMore (Defines.PREFIX, "share", "pixmaps",
|
||||||
|
"side-splash.png"));
|
||||||
|
|
||||||
|
VBox wrapper = new VBox (false, 0);
|
||||||
|
|
||||||
|
VBox layout_vertical = new VBox (false, 0) {
|
||||||
|
BorderWidth = 30
|
||||||
|
};
|
||||||
|
|
||||||
|
Label header = new Label ("<span size='x-large'><b>" +
|
||||||
|
_("Done!") +
|
||||||
|
"</b></span>") {
|
||||||
|
UseMarkup = true,
|
||||||
|
Xalign = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
Label information = new Label (_("Looks like the stars are aligned right for you!")) {
|
||||||
|
Xalign = 0,
|
||||||
|
Wrap = true
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
HButtonBox controls = new HButtonBox () {
|
||||||
|
BorderWidth = 12,
|
||||||
|
Layout = ButtonBoxStyle.End
|
||||||
|
};
|
||||||
|
|
||||||
|
Button finish_button = new Button (_("Finish"));
|
||||||
|
|
||||||
|
finish_button.Clicked += delegate (object o, EventArgs args) {
|
||||||
|
|
||||||
|
SparkleShare.SparkleUI.UpdateRepositories ();
|
||||||
|
Destroy ();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
controls.Add (finish_button);
|
||||||
|
|
||||||
|
layout_vertical.PackStart (header, false, false, 0);
|
||||||
|
layout_vertical.PackStart (information, false, false, 0);
|
||||||
|
|
||||||
|
wrapper.PackStart (layout_vertical, true, true, 0);
|
||||||
|
wrapper.PackStart (controls, false, true, 0);
|
||||||
|
|
||||||
|
layout_horizontal.PackStart (side_splash, false, false, 0);
|
||||||
|
layout_horizontal.PackStart (wrapper, true, true, 0);
|
||||||
|
|
||||||
|
Add (layout_horizontal);
|
||||||
|
|
||||||
|
ShowAll ();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void ShowStepTwoAndAHalf ()
|
private void ShowStepTwoAndAHalf ()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -358,11 +565,12 @@ namespace SparkleShare {
|
||||||
BorderWidth = 30
|
BorderWidth = 30
|
||||||
};
|
};
|
||||||
|
|
||||||
Label introduction = new Label ("<span size='x-large'><b>" +
|
Label header = new Label ("<span size='x-large'><b>" +
|
||||||
String.Format (_("Retrieving folder ‘{0}’…"), FolderEntry.Text) +
|
String.Format (_("Retrieving folder ‘{0}’…"), FolderEntry.Text) +
|
||||||
"</b></span>") {
|
"</b></span>") {
|
||||||
UseMarkup = true,
|
UseMarkup = true,
|
||||||
Xalign = 0
|
Xalign = 0,
|
||||||
|
Wrap = true
|
||||||
};
|
};
|
||||||
|
|
||||||
Label information = new Label ("<span fgcolor='#777'>" +
|
Label information = new Label ("<span fgcolor='#777'>" +
|
||||||
|
@ -411,7 +619,7 @@ namespace SparkleShare {
|
||||||
HBox box = new HBox (false, 0);
|
HBox box = new HBox (false, 0);
|
||||||
|
|
||||||
table.Attach (spinner, 0, 1, 0, 1);
|
table.Attach (spinner, 0, 1, 0, 1);
|
||||||
table.Attach (introduction, 1, 2, 0, 1);
|
table.Attach (header, 1, 2, 0, 1);
|
||||||
table.Attach (information, 1, 2, 1, 2);
|
table.Attach (information, 1, 2, 1, 2);
|
||||||
|
|
||||||
box.PackStart (table, false, false, 0);
|
box.PackStart (table, false, false, 0);
|
||||||
|
@ -451,7 +659,7 @@ namespace SparkleShare {
|
||||||
BorderWidth = 30
|
BorderWidth = 30
|
||||||
};
|
};
|
||||||
|
|
||||||
Label introduction = new Label ("<span size='x-large'><b>" +
|
Label header = new Label ("<span size='x-large'><b>" +
|
||||||
_("SparkleShare is ready to go!") +
|
_("SparkleShare is ready to go!") +
|
||||||
"</b></span>") {
|
"</b></span>") {
|
||||||
UseMarkup = true,
|
UseMarkup = true,
|
||||||
|
@ -473,7 +681,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
link_wrapper.PackStart (link, false, false, 0);
|
link_wrapper.PackStart (link, false, false, 0);
|
||||||
|
|
||||||
layout_vertical.PackStart (introduction, false, false, 0);
|
layout_vertical.PackStart (header, false, false, 0);
|
||||||
layout_vertical.PackStart (information, false, false, 21);
|
layout_vertical.PackStart (information, false, false, 21);
|
||||||
layout_vertical.PackStart (link_wrapper, false, false, 0);
|
layout_vertical.PackStart (link_wrapper, false, false, 0);
|
||||||
|
|
||||||
|
|
|
@ -52,9 +52,6 @@ namespace SparkleShare {
|
||||||
public delegate void FetchingFinishedEventHandler (object o, SparkleEventArgs args);
|
public delegate void FetchingFinishedEventHandler (object o, SparkleEventArgs args);
|
||||||
public delegate void NewCommitEventHandler (object o, NewCommitArgs args);
|
public delegate void NewCommitEventHandler (object o, NewCommitArgs args);
|
||||||
public delegate void ConflictDetectedEventHandler (object o, SparkleEventArgs args);
|
public delegate void ConflictDetectedEventHandler (object o, SparkleEventArgs args);
|
||||||
public delegate void CloningStartedEventHandler (object o, SparkleEventArgs args);
|
|
||||||
public delegate void CloningFinishedEventHandler (object o, SparkleEventArgs args);
|
|
||||||
public delegate void CloningFailedEventHandler (object o, SparkleEventArgs args);
|
|
||||||
|
|
||||||
public event AddedEventHandler Added;
|
public event AddedEventHandler Added;
|
||||||
public event CommitedEventHandler Commited;
|
public event CommitedEventHandler Commited;
|
||||||
|
@ -64,15 +61,13 @@ namespace SparkleShare {
|
||||||
public event FetchingFinishedEventHandler FetchingFinished;
|
public event FetchingFinishedEventHandler FetchingFinished;
|
||||||
public event NewCommitEventHandler NewCommit;
|
public event NewCommitEventHandler NewCommit;
|
||||||
public event ConflictDetectedEventHandler ConflictDetected;
|
public event ConflictDetectedEventHandler ConflictDetected;
|
||||||
public event CloningStartedEventHandler CloningStarted;
|
|
||||||
public event CloningFinishedEventHandler CloningFinished;
|
|
||||||
public event CloningFailedEventHandler CloningFailed;
|
|
||||||
|
|
||||||
|
|
||||||
public SparkleRepo (string path)
|
public SparkleRepo (string path)
|
||||||
{
|
{
|
||||||
|
|
||||||
// if (Directory.Exists)
|
if (!Directory.Exists (path))
|
||||||
|
Directory.CreateDirectory (path);
|
||||||
|
|
||||||
LocalPath = path;
|
LocalPath = path;
|
||||||
Name = Path.GetFileName (LocalPath);
|
Name = Path.GetFileName (LocalPath);
|
||||||
|
@ -140,74 +135,6 @@ namespace SparkleShare {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void Clone ()
|
|
||||||
{
|
|
||||||
|
|
||||||
SparkleEventArgs args = new SparkleEventArgs ("CloningStarted");
|
|
||||||
|
|
||||||
if (CloningStarted != null)
|
|
||||||
CloningStarted (this, args);
|
|
||||||
|
|
||||||
|
|
||||||
Process process = new Process () {
|
|
||||||
EnableRaisingEvents = true
|
|
||||||
};
|
|
||||||
|
|
||||||
process.StartInfo.RedirectStandardOutput = true;
|
|
||||||
process.StartInfo.UseShellExecute = false;
|
|
||||||
process.StartInfo.WorkingDirectory = SparklePaths.SparkleTmpPath;
|
|
||||||
process.StartInfo.Arguments = String.Format ("clone {0} {1}", RemoteOriginUrl, Name);
|
|
||||||
|
|
||||||
process.Start ();
|
|
||||||
|
|
||||||
process.Exited += delegate {
|
|
||||||
|
|
||||||
if (Process.ExitCode != 0) {
|
|
||||||
|
|
||||||
args = new SparkleEventArgs ("CloningFailed");
|
|
||||||
|
|
||||||
if (CloningFailed != null)
|
|
||||||
CloningFailed (this, args);
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
|
||||||
Directory.Delete (SparkleHelpers.CombineMore (SparklePaths.SparkleTmpPath, Name));
|
|
||||||
} catch (System.IO.DirectoryNotFoundException) {
|
|
||||||
SparkleHelpers.DebugInfo ("Config", "[" + Name + "] Temporary directory did not exist...");
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
args = new SparkleEventArgs ("CloningFinished");
|
|
||||||
|
|
||||||
if (CloningFinished != null)
|
|
||||||
CloningFinished (this, args);
|
|
||||||
|
|
||||||
|
|
||||||
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Repository cloned");
|
|
||||||
|
|
||||||
Directory.Move (SparkleHelpers.CombineMore (SparklePaths.SparkleTmpPath, Name),
|
|
||||||
SparkleHelpers.CombineMore (SparklePaths.SparklePath, Name));
|
|
||||||
|
|
||||||
// Add a .gitignore file to the repo
|
|
||||||
TextWriter writer = new StreamWriter (SparkleHelpers.CombineMore (SparklePaths.SparklePath, Name,
|
|
||||||
".git/info/exclude"));
|
|
||||||
|
|
||||||
writer.WriteLine ("*~"); // Ignore gedit swap files
|
|
||||||
writer.WriteLine (".*.sw?"); // Ignore vi swap files
|
|
||||||
writer.WriteLine (".DS_store"); // Ignore OSX's invisible directories
|
|
||||||
|
|
||||||
writer.Close ();
|
|
||||||
|
|
||||||
// TODO: Install username and email from global file
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void CheckForChanges ()
|
private void CheckForChanges ()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// 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 Gtk;
|
using Gtk;
|
||||||
using Mono.Unix;
|
using Mono.Unix;
|
||||||
|
|
|
@ -308,18 +308,6 @@ namespace SparkleShare {
|
||||||
Application.Invoke (UpdateStatusIconToIdle);
|
Application.Invoke (UpdateStatusIconToIdle);
|
||||||
};
|
};
|
||||||
|
|
||||||
repo.CloningStarted += delegate {
|
|
||||||
Application.Invoke (UpdateStatusIconToSyncing);
|
|
||||||
};
|
|
||||||
|
|
||||||
repo.CloningFinished += delegate {
|
|
||||||
Application.Invoke (UpdateStatusIconToIdle);
|
|
||||||
};
|
|
||||||
|
|
||||||
repo.CloningFailed += delegate {
|
|
||||||
Application.Invoke (UpdateStatusIconToIdle);
|
|
||||||
};
|
|
||||||
|
|
||||||
repo.PushingStarted += delegate {
|
repo.PushingStarted += delegate {
|
||||||
Application.Invoke (UpdateStatusIconToSyncing);
|
Application.Invoke (UpdateStatusIconToSyncing);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue