conflict resolution
This commit is contained in:
parent
33c5abdc5a
commit
26df85cf34
|
@ -153,13 +153,21 @@ namespace SparkleShare {
|
||||||
BufferTimer.Elapsed += delegate (object o, ElapsedEventArgs args) {
|
BufferTimer.Elapsed += delegate (object o, ElapsedEventArgs args) {
|
||||||
Console.WriteLine ("[Buffer][" + Name + "] Done waiting.");
|
Console.WriteLine ("[Buffer][" + Name + "] Done waiting.");
|
||||||
Add ();
|
Add ();
|
||||||
|
string Message = FormatCommitMessage ();
|
||||||
|
if (!Message.Equals ("")) {
|
||||||
|
Commit (Message);
|
||||||
|
Push ();
|
||||||
|
Fetch ();
|
||||||
|
// Push again in case of a conflict
|
||||||
|
Push ();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
FetchTimer.Start ();
|
FetchTimer.Start ();
|
||||||
|
|
||||||
BufferTimer.Start();
|
BufferTimer.Start();
|
||||||
Console.WriteLine ("[Buffer][" + Name + "] " +
|
Console.WriteLine ("[Buffer][" + Name + "] " +
|
||||||
"Waiting for more changes...");
|
"Waiting for more changes...");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -185,14 +193,6 @@ namespace SparkleShare {
|
||||||
Process.WaitForExit ();
|
Process.WaitForExit ();
|
||||||
Console.WriteLine ("[Git][" + Name + "] Changes staged.");
|
Console.WriteLine ("[Git][" + Name + "] Changes staged.");
|
||||||
// SparkleUI.NotificationIcon.SetSyncingState ();
|
// SparkleUI.NotificationIcon.SetSyncingState ();
|
||||||
string Message = FormatCommitMessage ();
|
|
||||||
if (!Message.Equals ("")) {
|
|
||||||
Commit (Message);
|
|
||||||
Push ();
|
|
||||||
Fetch ();
|
|
||||||
// Push again in case of a conflict
|
|
||||||
Push ();
|
|
||||||
}
|
|
||||||
// SparkleUI.NotificationIcon.SetIdleState ();
|
// SparkleUI.NotificationIcon.SetIdleState ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,9 +231,60 @@ namespace SparkleShare {
|
||||||
Process.Start();
|
Process.Start();
|
||||||
Console.WriteLine ("[Git][" + Name + "] Changes rebased.");
|
Console.WriteLine ("[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
|
||||||
if (!Output.Contains ("up to date")) {
|
if (!Output.Contains ("up to date")) {
|
||||||
|
|
||||||
|
if (Output.Contains ("Failed to merge")) {
|
||||||
|
|
||||||
|
Console.WriteLine ("[Git][" + Name + "] Resolving conflict... ");
|
||||||
|
|
||||||
|
Process.StartInfo.Arguments = "status";
|
||||||
|
Process.WaitForExit ();
|
||||||
|
Process.Start();
|
||||||
|
|
||||||
|
foreach (string Line in Regex.Split (Output, "\n")) {
|
||||||
|
|
||||||
|
if (Line.Contains ("needs merge")) {
|
||||||
|
|
||||||
|
string ProblemFileName =
|
||||||
|
Line.Substring (Line.IndexOf (": needs merge"));
|
||||||
|
|
||||||
|
Process.StartInfo.Arguments
|
||||||
|
= "checkout --ours " + ProblemFileName;
|
||||||
|
Process.WaitForExit ();
|
||||||
|
Process.Start();
|
||||||
|
|
||||||
|
DateTime DateTime = new DateTime ();
|
||||||
|
string TimeStamp =
|
||||||
|
String.Format("{0:H:mm, d MMM yyyy}", DateTime);
|
||||||
|
|
||||||
|
File.Move (ProblemFileName,
|
||||||
|
ProblemFileName + " (" + UserName + " - " +
|
||||||
|
TimeStamp);
|
||||||
|
|
||||||
|
Process.StartInfo.Arguments
|
||||||
|
= "checkout --theirs " + ProblemFileName;
|
||||||
|
Process.WaitForExit ();
|
||||||
|
Process.Start();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Add ();
|
||||||
|
|
||||||
|
Process.StartInfo.Arguments
|
||||||
|
= "rebase --continue";
|
||||||
|
Process.WaitForExit ();
|
||||||
|
Process.Start();
|
||||||
|
Console.WriteLine ("[Git][" + Name + "] Conflict resolved.");
|
||||||
|
|
||||||
|
Push ();
|
||||||
|
Fetch ();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Get the last committer e-mail
|
// Get the last committer e-mail
|
||||||
Process.StartInfo.Arguments = "log --format=\"%ae\" -1";
|
Process.StartInfo.Arguments = "log --format=\"%ae\" -1";
|
||||||
Process.Start();
|
Process.Start();
|
||||||
|
@ -260,7 +311,6 @@ namespace SparkleShare {
|
||||||
SparkleHelpers.GetAvatar (LastCommitEmail, 48),
|
SparkleHelpers.GetAvatar (LastCommitEmail, 48),
|
||||||
true);
|
true);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Watcher.EnableRaisingEvents = true;
|
Watcher.EnableRaisingEvents = true;
|
||||||
|
|
Loading…
Reference in a new issue