fix some order bugs
This commit is contained in:
parent
7d30274f8a
commit
0b2db44fe1
|
@ -241,11 +241,11 @@ public class Repository {
|
||||||
// Get the domain, example: "github.com"
|
// Get the domain, example: "github.com"
|
||||||
Domain = RemoteOriginUrl;
|
Domain = RemoteOriginUrl;
|
||||||
Domain = Domain.Substring (Domain.IndexOf ("@") + 1);
|
Domain = Domain.Substring (Domain.IndexOf ("@") + 1);
|
||||||
if (Domain.IndexOf (":") > -1) {
|
if (Domain.IndexOf (":") > -1)
|
||||||
Domain = Domain.Substring (0, Domain.IndexOf (":"));
|
Domain = Domain.Substring (0, Domain.IndexOf (":"));
|
||||||
} else {
|
else
|
||||||
Domain = Domain.Substring (0, Domain.IndexOf ("/"));
|
Domain = Domain.Substring (0, Domain.IndexOf ("/"));
|
||||||
}
|
|
||||||
|
|
||||||
// Get hash of the current commit
|
// Get hash of the current commit
|
||||||
Process.StartInfo.FileName = "git";
|
Process.StartInfo.FileName = "git";
|
||||||
|
@ -253,8 +253,6 @@ public class Repository {
|
||||||
Process.Start();
|
Process.Start();
|
||||||
CurrentHash = Process.StandardOutput.ReadToEnd().Trim ();
|
CurrentHash = Process.StandardOutput.ReadToEnd().Trim ();
|
||||||
|
|
||||||
|
|
||||||
// TODO: This does not belong in this class...
|
|
||||||
// Watch the repository's folder
|
// Watch the repository's folder
|
||||||
Watcher = new FileSystemWatcher (RepoPath);
|
Watcher = new FileSystemWatcher (RepoPath);
|
||||||
Watcher.IncludeSubdirectories = true;
|
Watcher.IncludeSubdirectories = true;
|
||||||
|
@ -266,33 +264,11 @@ public class Repository {
|
||||||
|
|
||||||
BufferTimer = new Timer ();
|
BufferTimer = new Timer ();
|
||||||
|
|
||||||
// TODO: uncomment when status checking is implemented
|
// Add everything that changed since SparklePony was stopped
|
||||||
// Add ();
|
Add ();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StartBufferTimer () {
|
|
||||||
|
|
||||||
int Interval = 5000;
|
|
||||||
if (!BufferTimer.Enabled) {
|
|
||||||
|
|
||||||
// Delay for a few seconds to see if more files change
|
|
||||||
BufferTimer.Interval = Interval;
|
|
||||||
BufferTimer.Elapsed += delegate (object o, ElapsedEventArgs args) { Add (); } ;
|
|
||||||
Console.WriteLine ("[Buffer] Waiting for more changes...");
|
|
||||||
BufferTimer.Start();
|
|
||||||
} else {
|
|
||||||
|
|
||||||
// Extend the delay when something changes
|
|
||||||
BufferTimer.Close ();
|
|
||||||
BufferTimer = new Timer ();
|
|
||||||
BufferTimer.Interval = Interval;
|
|
||||||
BufferTimer.Elapsed += delegate (object o, ElapsedEventArgs args) { Add (); } ;
|
|
||||||
BufferTimer.Start();
|
|
||||||
Console.WriteLine ("[Buffer] Waiting for more changes...");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnFileActivity (object o, FileSystemEventArgs args) {
|
public void OnFileActivity (object o, FileSystemEventArgs args) {
|
||||||
WatcherChangeTypes wct = args.ChangeType;
|
WatcherChangeTypes wct = args.ChangeType;
|
||||||
if (!ShouldIgnore (args.Name)) {
|
if (!ShouldIgnore (args.Name)) {
|
||||||
|
@ -301,34 +277,63 @@ public class Repository {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void StartBufferTimer () {
|
||||||
|
|
||||||
|
int Interval = 5000;
|
||||||
|
if (!BufferTimer.Enabled) {
|
||||||
|
|
||||||
|
// Delay for a few seconds to see if more files change
|
||||||
|
BufferTimer.Interval = Interval;
|
||||||
|
BufferTimer.Elapsed += delegate (object o, ElapsedEventArgs args) {
|
||||||
|
Console.WriteLine ("[Buffer] Done waiting.");
|
||||||
|
Add ();
|
||||||
|
};
|
||||||
|
Console.WriteLine ("[Buffer] Waiting for more changes...");
|
||||||
|
BufferTimer.Start();
|
||||||
|
} else {
|
||||||
|
|
||||||
|
// Extend the delay when something changes
|
||||||
|
BufferTimer.Close ();
|
||||||
|
BufferTimer = new Timer ();
|
||||||
|
BufferTimer.Interval = Interval;
|
||||||
|
BufferTimer.Elapsed += delegate (object o, ElapsedEventArgs args) {
|
||||||
|
Console.WriteLine ("[Buffer] Done waiting.");
|
||||||
|
Add ();
|
||||||
|
};
|
||||||
|
BufferTimer.Start();
|
||||||
|
Console.WriteLine ("[Buffer] Waiting for more changes...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Clone () {
|
public void Clone () {
|
||||||
Process.StartInfo.Arguments = "clone " + RemoteOriginUrl;
|
Process.StartInfo.Arguments = "clone " + RemoteOriginUrl;
|
||||||
Process.Start();
|
Process.Start();
|
||||||
|
|
||||||
// Add a gitignore file
|
// Add a gitignore file
|
||||||
Process.StartInfo.FileName = "/bin/sh";
|
Process.StartInfo.FileName = "touch";
|
||||||
Process.StartInfo.Arguments = "echo \"*~\" >> " + RepoPath + "/.gitignore";
|
Process.StartInfo.Arguments = RepoPath + "/.gitignore";
|
||||||
Process.Start();
|
Process.Start();
|
||||||
|
// TODO: add *~ contents.
|
||||||
Process.StartInfo.FileName = "git";
|
Process.StartInfo.FileName = "git";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Add () {
|
public void Add () {
|
||||||
Console.WriteLine ("[Buffer] Done waiting.");
|
|
||||||
BufferTimer.Stop ();
|
BufferTimer.Stop ();
|
||||||
Console.WriteLine ("[Git] Staging changes...");
|
Console.WriteLine ("[Git] Staging changes...");
|
||||||
Process.StartInfo.Arguments = "add --all";
|
Process.StartInfo.Arguments = "add --all";
|
||||||
Process.Start();
|
Process.Start();
|
||||||
|
|
||||||
Commit (FormatCommitMessage ());
|
string Message = FormatCommitMessage ();
|
||||||
|
if (!Message.Equals ("")) {
|
||||||
Fetch ();
|
Commit (Message);
|
||||||
Push ();
|
Fetch ();
|
||||||
|
Push ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Commit (string Message) {
|
public void Commit (string Message) {
|
||||||
Console.WriteLine (Message);
|
Console.WriteLine ("[Commit] " + Message);
|
||||||
Console.WriteLine ("[Git] Commiting changes...");
|
Console.WriteLine ("[Git] Commiting changes...");
|
||||||
Process.StartInfo.Arguments = "commit -m '" + Message + "'";
|
Process.StartInfo.Arguments = "commit -m '" + Message + "'";
|
||||||
Process.Start();
|
Process.Start();
|
||||||
|
@ -374,9 +379,9 @@ public class Repository {
|
||||||
|
|
||||||
public void Push () {
|
public void Push () {
|
||||||
// TODO: What happens when network disconnects during a push
|
// TODO: What happens when network disconnects during a push
|
||||||
|
Console.WriteLine ("[Git] Pushing changes...");
|
||||||
Process.StartInfo.Arguments = "push";
|
Process.StartInfo.Arguments = "push";
|
||||||
Process.Start();
|
Process.Start();
|
||||||
Console.WriteLine ("[Git] Pushing changes...");
|
|
||||||
Process.WaitForExit ();
|
Process.WaitForExit ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -463,7 +468,7 @@ public class Repository {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return "Nothing seems to have happened, strange...";
|
return "";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -528,6 +533,7 @@ public class SparklePonyWindow : Window {
|
||||||
ListStore LogStore = new ListStore (typeof (Gdk.Pixbuf), typeof (string), typeof (string));
|
ListStore LogStore = new ListStore (typeof (Gdk.Pixbuf), typeof (string), typeof (string));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Process Process = new Process();
|
Process Process = new Process();
|
||||||
Process.EnableRaisingEvents = false;
|
Process.EnableRaisingEvents = false;
|
||||||
Process.StartInfo.RedirectStandardOutput = true;
|
Process.StartInfo.RedirectStandardOutput = true;
|
||||||
|
|
Loading…
Reference in a new issue