make debuginfo optional and add timestamps
This commit is contained in:
parent
515a209340
commit
85ca04bd9a
|
@ -26,6 +26,8 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public static class SparkleHelpers {
|
public static class SparkleHelpers {
|
||||||
|
|
||||||
|
public static bool ShowDebugInfo = true;
|
||||||
|
|
||||||
public static Gdk.Pixbuf GetAvatar (string Email, int Size) {
|
public static Gdk.Pixbuf GetAvatar (string Email, int Size) {
|
||||||
|
|
||||||
string AvatarPath = Path.Combine (SparklePaths.SparkleAvatarPath,
|
string AvatarPath = Path.Combine (SparklePaths.SparkleAvatarPath,
|
||||||
|
@ -103,6 +105,15 @@ namespace SparkleShare {
|
||||||
return Regex.Match (Url, @"[a-z]+://(.)+(/|:)(.)+").Success;
|
return Regex.Match (Url, @"[a-z]+://(.)+(/|:)(.)+").Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void DebugInfo (string Type, string Message) {
|
||||||
|
if (ShowDebugInfo) {
|
||||||
|
DateTime DateTime = new DateTime ();
|
||||||
|
string TimeStamp = DateTime.Now.ToString ("HH:mm:ss");
|
||||||
|
Console.WriteLine ("[" + TimeStamp + "]" +
|
||||||
|
"[" + Type + "]" + Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,7 @@ namespace SparkleShare {
|
||||||
BufferTimer = new Timer ();
|
BufferTimer = new Timer ();
|
||||||
|
|
||||||
BufferTimer.Elapsed += delegate (object o, ElapsedEventArgs args) {
|
BufferTimer.Elapsed += delegate (object o, ElapsedEventArgs args) {
|
||||||
Console.WriteLine ("[Buffer][" + Name + "] Done waiting.");
|
SparkleHelpers.DebugInfo ("Buffer", "[" + Name + "] Done waiting.");
|
||||||
Add ();
|
Add ();
|
||||||
string Message = FormatCommitMessage ();
|
string Message = FormatCommitMessage ();
|
||||||
if (!Message.Equals ("")) {
|
if (!Message.Equals ("")) {
|
||||||
|
@ -127,16 +127,17 @@ namespace SparkleShare {
|
||||||
// since SparkleShare was stopped
|
// since SparkleShare was stopped
|
||||||
Add ();
|
Add ();
|
||||||
|
|
||||||
Console.WriteLine ("[Git][" + Name + "] Nothing going on...");
|
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Nothing going on...");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Starts a time buffer when something changes
|
// Starts a time buffer when something 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)) {
|
||||||
Console.WriteLine ("[Event][" + Name + "] " + wct.ToString () +
|
SparkleHelpers.DebugInfo ("Event", "[" + Name + "] "
|
||||||
" '" + args.Name + "'");
|
+ wct.ToString () +
|
||||||
|
" '" + args.Name + "'");
|
||||||
StartBufferTimer ();
|
StartBufferTimer ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -152,11 +153,14 @@ namespace SparkleShare {
|
||||||
// Delay for a few seconds to see if more files change
|
// Delay for a few seconds to see if more files change
|
||||||
BufferTimer.Interval = Interval;
|
BufferTimer.Interval = Interval;
|
||||||
BufferTimer.Elapsed += delegate (object o, ElapsedEventArgs args) {
|
BufferTimer.Elapsed += delegate (object o, ElapsedEventArgs args) {
|
||||||
Console.WriteLine ("[Buffer][" + Name + "] Done waiting.");
|
SparkleHelpers.DebugInfo ("Buffer",
|
||||||
|
"[" + Name + "] Done waiting.");
|
||||||
Add ();
|
Add ();
|
||||||
};
|
};
|
||||||
Console.WriteLine ("[Buffer][" + Name + "] " +
|
|
||||||
"Waiting for more changes...");
|
SparkleHelpers.DebugInfo ("Buffer",
|
||||||
|
"[" + Name + "] " +
|
||||||
|
"Waiting for more changes...");
|
||||||
|
|
||||||
BufferTimer.Start ();
|
BufferTimer.Start ();
|
||||||
|
|
||||||
|
@ -170,8 +174,9 @@ namespace SparkleShare {
|
||||||
FetchTimer.Start ();
|
FetchTimer.Start ();
|
||||||
|
|
||||||
BufferTimer.Start ();
|
BufferTimer.Start ();
|
||||||
Console.WriteLine ("[Buffer][" + Name + "] " +
|
SparkleHelpers.DebugInfo ("Buffer",
|
||||||
"Waiting for more changes...");
|
"[" + Name + "] " +
|
||||||
|
"Waiting for more changes...");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -192,11 +197,11 @@ namespace SparkleShare {
|
||||||
public void Add () {
|
public void Add () {
|
||||||
BufferTimer.Stop ();
|
BufferTimer.Stop ();
|
||||||
FetchTimer.Stop ();
|
FetchTimer.Stop ();
|
||||||
Console.WriteLine ("[Git][" + Name + "] Staging changes...");
|
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Staging changes...");
|
||||||
Process.StartInfo.Arguments = "add --all";
|
Process.StartInfo.Arguments = "add --all";
|
||||||
Process.Start ();
|
Process.Start ();
|
||||||
Process.WaitForExit ();
|
Process.WaitForExit ();
|
||||||
Console.WriteLine ("[Git][" + Name + "] Changes staged.");
|
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Changes staged.");
|
||||||
// SparkleUI.NotificationIcon.SetSyncingState ();
|
// SparkleUI.NotificationIcon.SetSyncingState ();
|
||||||
// SparkleUI.NotificationIcon.SetIdleState ();
|
// SparkleUI.NotificationIcon.SetIdleState ();
|
||||||
FetchTimer.Start ();
|
FetchTimer.Start ();
|
||||||
|
@ -204,24 +209,23 @@ namespace SparkleShare {
|
||||||
|
|
||||||
// Commits the made changes
|
// Commits the made changes
|
||||||
public void Commit (string Message) {
|
public void Commit (string Message) {
|
||||||
Console.WriteLine ("[Commit][" + Name + "] " + Message);
|
SparkleHelpers.DebugInfo ("Commit",
|
||||||
Console.WriteLine ("[Git][" + Name + "] Commiting changes...");
|
"[" + Name + "] " + Message);
|
||||||
Process.StartInfo.Arguments = "commit -m \"" + Message + "\"";
|
Process.StartInfo.Arguments = "commit -m \"" + Message + "\"";
|
||||||
Process.Start ();
|
Process.Start ();
|
||||||
Process.WaitForExit ();
|
Process.WaitForExit ();
|
||||||
Console.WriteLine ("[Git][" + Name + "] Changes commited.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetches changes from the remote repo
|
// Fetches changes from the remote repo
|
||||||
public void Fetch () {
|
public void Fetch () {
|
||||||
FetchTimer.Stop ();
|
FetchTimer.Stop ();
|
||||||
// SparkleUI.NotificationIcon.SetSyncingState ();
|
// SparkleUI.NotificationIcon.SetSyncingState ();
|
||||||
Console.WriteLine ("[Git][" + Name + "] Fetching changes... ");
|
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Fetching changes...");
|
||||||
Process.StartInfo.Arguments = "fetch -v";
|
Process.StartInfo.Arguments = "fetch -v";
|
||||||
Process.Start ();
|
Process.Start ();
|
||||||
string Output = Process.StandardOutput.ReadToEnd ().Trim (); // TODO: This doesn't work :(
|
string Output = Process.StandardOutput.ReadToEnd ().Trim (); // TODO: This doesn't work :(
|
||||||
Process.WaitForExit ();
|
Process.WaitForExit ();
|
||||||
Console.WriteLine ("[Git][" + Name + "] Changes fetched.");
|
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Changes fetched.");
|
||||||
if (!Output.Contains ("up to date"))
|
if (!Output.Contains ("up to date"))
|
||||||
Rebase ();
|
Rebase ();
|
||||||
// SparkleUI.NotificationIcon.SetIdleState ();
|
// SparkleUI.NotificationIcon.SetIdleState ();
|
||||||
|
@ -233,11 +237,11 @@ namespace SparkleShare {
|
||||||
|
|
||||||
Watcher.EnableRaisingEvents = false;
|
Watcher.EnableRaisingEvents = false;
|
||||||
|
|
||||||
Console.WriteLine ("[Git][" + Name + "] Rebasing fetched changes... ");
|
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Rebasing changes...");
|
||||||
Process.StartInfo.Arguments = "rebase origin";
|
Process.StartInfo.Arguments = "rebase origin";
|
||||||
Process.WaitForExit ();
|
Process.WaitForExit ();
|
||||||
Process.Start ();
|
Process.Start ();
|
||||||
Console.WriteLine ("[Git][" + Name + "] Changes rebased.");
|
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Changes rebased.");
|
||||||
string Output = Process.StandardOutput.ReadToEnd ().Trim ();
|
string Output = Process.StandardOutput.ReadToEnd ().Trim ();
|
||||||
|
|
||||||
// Show notification if there are updates
|
// Show notification if there are updates
|
||||||
|
@ -245,7 +249,8 @@ namespace SparkleShare {
|
||||||
|
|
||||||
if (Output.Contains ("Failed to merge")) {
|
if (Output.Contains ("Failed to merge")) {
|
||||||
|
|
||||||
Console.WriteLine ("[Git][" + Name + "] Resolving conflict... ");
|
SparkleHelpers.DebugInfo ("Git",
|
||||||
|
"[" + Name + "] Resolving conflict...");
|
||||||
|
|
||||||
Process.StartInfo.Arguments = "status";
|
Process.StartInfo.Arguments = "status";
|
||||||
Process.WaitForExit ();
|
Process.WaitForExit ();
|
||||||
|
@ -266,8 +271,8 @@ namespace SparkleShare {
|
||||||
|
|
||||||
DateTime DateTime = new DateTime ();
|
DateTime DateTime = new DateTime ();
|
||||||
string TimeStamp =
|
string TimeStamp =
|
||||||
String.Format ("{0:H:mm, d MMM yyyy}", DateTime);
|
DateTime.Now.ToString ("H:mm, d MMM yyyy");
|
||||||
|
|
||||||
File.Move (ProblemFileName,
|
File.Move (ProblemFileName,
|
||||||
ProblemFileName + " (" + UserName + " - " +
|
ProblemFileName + " (" + UserName + " - " +
|
||||||
TimeStamp + ")");
|
TimeStamp + ")");
|
||||||
|
@ -291,8 +296,8 @@ namespace SparkleShare {
|
||||||
Process.StartInfo.Arguments = "rebase --continue";
|
Process.StartInfo.Arguments = "rebase --continue";
|
||||||
Process.WaitForExit ();
|
Process.WaitForExit ();
|
||||||
Process.Start ();
|
Process.Start ();
|
||||||
Console.WriteLine ("[Git][" + Name + "] Conflict resolved.");
|
SparkleHelpers.DebugInfo ("Git",
|
||||||
|
"[" + Name + "] Conflict resolved.");
|
||||||
Push ();
|
Push ();
|
||||||
Fetch ();
|
Fetch ();
|
||||||
|
|
||||||
|
@ -320,27 +325,28 @@ namespace SparkleShare {
|
||||||
SparkleHelpers.CombineMore (SparklePaths.SparkleConfigPath,
|
SparkleHelpers.CombineMore (SparklePaths.SparkleConfigPath,
|
||||||
"sparkleshare.notify");
|
"sparkleshare.notify");
|
||||||
|
|
||||||
Console.WriteLine ("[Git][" + Name + "] Showing notification.");
|
if (File.Exists (NotifySettingFile)) {
|
||||||
|
SparkleHelpers.DebugInfo ("Notification",
|
||||||
if (File.Exists (NotifySettingFile))
|
"[" + Name + "] Showing message...");
|
||||||
ShowEventBubble (LastCommitUserName + " " + LastCommitMessage,
|
ShowEventBubble (LastCommitUserName + " " + LastCommitMessage,
|
||||||
SparkleHelpers.GetAvatar (LastCommitEmail, 48),
|
SparkleHelpers.GetAvatar (LastCommitEmail, 48),
|
||||||
true);
|
true);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Watcher.EnableRaisingEvents = true;
|
Watcher.EnableRaisingEvents = true;
|
||||||
Console.WriteLine ("[Git][" + Name + "] Nothing going on... ");
|
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Nothing going on...");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pushes the changes to the remote repo
|
// Pushes the changes to the remote repo
|
||||||
public void Push () {
|
public void Push () {
|
||||||
Console.WriteLine ("[Git][" + Name + "] Pushing changes...");
|
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Pushing changes...");
|
||||||
Process.StartInfo.Arguments = "push";
|
Process.StartInfo.Arguments = "push";
|
||||||
Process.Start ();
|
Process.Start ();
|
||||||
Process.WaitForExit ();
|
Process.WaitForExit ();
|
||||||
Console.WriteLine ("[Git][" + Name + "] Changes pushed.");
|
SparkleHelpers.DebugInfo ("Git", "[" + Name + "] Changes pushed.");
|
||||||
// SparkleUI.NotificationIcon.SetIdleState ();
|
// SparkleUI.NotificationIcon.SetIdleState ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue