Support showing merge commits in logs (and fix crashes caused by them being missing)

This commit is contained in:
Hylke Bons 2011-03-03 12:06:25 +00:00
parent 46c91560c4
commit 3061844ee7
5 changed files with 34 additions and 12 deletions

View file

@ -26,6 +26,7 @@ namespace SparkleLib {
public string UserEmail;
public DateTime DateTime;
public string Hash;
public bool IsMerge;
public List <string> Added;
public List <string> Deleted;

View file

@ -771,7 +771,7 @@ namespace SparkleLib {
git.WaitForExit ();
_CurrentHash = Head.CurrentCommit.Hash;
Console.WriteLine ("!!!!" + LocalPath + ": " + GetCommits (1).Count);
if (NewCommit != null)
NewCommit (GetCommits (1) [0], LocalPath);
@ -976,12 +976,30 @@ namespace SparkleLib {
foreach (string log_entry in entries) {
Regex regex;
bool is_merge_commit = false;
if (log_entry.Contains ("\nMerge: ")) {
regex = new Regex (@"commit ([a-z0-9]{40})\n" +
"Merge: .+ .+\n" +
"Author: (.+) <(.+)>\n" +
"Date: ([0-9]{4})-([0-9]{2})-([0-9]{2}) " +
"([0-9]{2}):([0-9]{2}):([0-9]{2}) \\+([0-9]{4})\n" +
"*");
is_merge_commit = true;
Regex regex = new Regex (@"commit ([a-z0-9]{40})\n" +
"Author: (.+) <(.+)>\n" +
"Date: ([0-9]{4})-([0-9]{2})-([0-9]{2}) " +
"([0-9]{2}):([0-9]{2}):([0-9]{2}) \\+([0-9]{4})\n" +
"*");
} else {
regex = new Regex (@"commit ([a-z0-9]{40})\n" +
"Author: (.+) <(.+)>\n" +
"Date: ([0-9]{4})-([0-9]{2})-([0-9]{2}) " +
"([0-9]{2}):([0-9]{2}):([0-9]{2}) \\+([0-9]{4})\n" +
"*");
}
Match match = regex.Match (log_entry);
@ -989,9 +1007,10 @@ namespace SparkleLib {
SparkleCommit commit = new SparkleCommit ();
commit.Hash = match.Groups [1].Value;
commit.UserName = match.Groups [2].Value;
commit.UserEmail = match.Groups [3].Value;
commit.Hash = match.Groups [1].Value;
commit.UserName = match.Groups [2].Value;
commit.UserEmail = match.Groups [3].Value;
commit.IsMerge = is_merge_commit;
commit.DateTime = new DateTime (int.Parse (match.Groups [4].Value),
int.Parse (match.Groups [5].Value), int.Parse (match.Groups [6].Value),

View file

@ -317,7 +317,9 @@ namespace SparkleShare {
}
}
if (change_set.IsMerge)
event_entry += "<dt>Merged a branch</dt>";
if (change_set.Added.Count > 0) {

View file

@ -103,7 +103,7 @@ namespace SparkleShare {
}
if (!hide_ui) {
if (Controller != null) {
UI = new SparkleUI ();
UI.Run ();

View file

@ -51,7 +51,7 @@ namespace SparkleShare {
StatusIcon = new SparkleStatusIcon ();
// Keep track of which event logs are open
SparkleUI.OpenLogs = new List <SparkleLog> ();
OpenLogs = new List <SparkleLog> ();
if (SparkleShare.Controller.FirstRun) {