lib git: treat merge commits like any other commit
This commit is contained in:
parent
f28fd55fdc
commit
6569ae6200
|
@ -584,30 +584,14 @@ namespace SparkleLib.Git {
|
||||||
|
|
||||||
entries.Add (last_entry);
|
entries.Add (last_entry);
|
||||||
|
|
||||||
Regex merge_regex = new Regex (@"commit ([a-z0-9]{40})\n" +
|
Regex 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" +
|
|
||||||
"*", RegexOptions.Compiled);
|
|
||||||
|
|
||||||
Regex non_merge_regex = new Regex (@"commit ([a-z0-9]{40})\n" +
|
|
||||||
"Author: (.+) <(.+)>\n" +
|
"Author: (.+) <(.+)>\n" +
|
||||||
|
"*" +
|
||||||
"Date: ([0-9]{4})-([0-9]{2})-([0-9]{2}) " +
|
"Date: ([0-9]{4})-([0-9]{2})-([0-9]{2}) " +
|
||||||
"([0-9]{2}):([0-9]{2}):([0-9]{2}) (.[0-9]{4})\n" +
|
"([0-9]{2}):([0-9]{2}):([0-9]{2}) (.[0-9]{4})\n" +
|
||||||
"*", RegexOptions.Compiled);
|
"*", RegexOptions.Compiled);
|
||||||
|
|
||||||
foreach (string log_entry in entries) {
|
foreach (string log_entry in entries) {
|
||||||
Regex regex;
|
|
||||||
bool is_merge_commit = false;
|
|
||||||
|
|
||||||
if (log_entry.Contains ("\nMerge: ")) {
|
|
||||||
regex = merge_regex;
|
|
||||||
is_merge_commit = true;
|
|
||||||
} else {
|
|
||||||
regex = non_merge_regex;
|
|
||||||
}
|
|
||||||
|
|
||||||
Match match = regex.Match (log_entry);
|
Match match = regex.Match (log_entry);
|
||||||
|
|
||||||
if (match.Success) {
|
if (match.Success) {
|
||||||
|
@ -616,7 +600,6 @@ namespace SparkleLib.Git {
|
||||||
change_set.Folder = new SparkleFolder (Name);
|
change_set.Folder = new SparkleFolder (Name);
|
||||||
change_set.Revision = match.Groups [1].Value;
|
change_set.Revision = match.Groups [1].Value;
|
||||||
change_set.User = new SparkleUser (match.Groups [2].Value, match.Groups [3].Value);
|
change_set.User = new SparkleUser (match.Groups [2].Value, match.Groups [3].Value);
|
||||||
change_set.IsMagical = is_merge_commit;
|
|
||||||
change_set.RemoteUrl = RemoteUrl;
|
change_set.RemoteUrl = RemoteUrl;
|
||||||
|
|
||||||
change_set.Timestamp = new DateTime (int.Parse (match.Groups [4].Value),
|
change_set.Timestamp = new DateTime (int.Parse (match.Groups [4].Value),
|
||||||
|
@ -688,7 +671,7 @@ namespace SparkleLib.Git {
|
||||||
change_set.Changes.Add (
|
change_set.Changes.Add (
|
||||||
new SparkleChange () {
|
new SparkleChange () {
|
||||||
Path = file_path,
|
Path = file_path,
|
||||||
MovedPath = to_file_path,
|
MovedToPath = to_file_path,
|
||||||
Timestamp = change_set.Timestamp,
|
Timestamp = change_set.Timestamp,
|
||||||
Type = SparkleChangeType.Moved
|
Type = SparkleChangeType.Moved
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,12 +32,13 @@ namespace SparkleLib {
|
||||||
public class SparkleChangeSet {
|
public class SparkleChangeSet {
|
||||||
|
|
||||||
public SparkleUser User = new SparkleUser ("Unknown", "Unknown");
|
public SparkleUser User = new SparkleUser ("Unknown", "Unknown");
|
||||||
|
|
||||||
public SparkleFolder Folder;
|
public SparkleFolder Folder;
|
||||||
|
public Uri RemoteUrl;
|
||||||
|
|
||||||
public string Revision;
|
public string Revision;
|
||||||
public DateTime Timestamp;
|
public DateTime Timestamp;
|
||||||
public DateTime FirstTimestamp;
|
public DateTime FirstTimestamp;
|
||||||
public bool IsMagical;
|
|
||||||
public Uri RemoteUrl;
|
|
||||||
public List<SparkleChange> Changes = new List<SparkleChange> ();
|
public List<SparkleChange> Changes = new List<SparkleChange> ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +47,7 @@ namespace SparkleLib {
|
||||||
|
|
||||||
public SparkleChangeType Type;
|
public SparkleChangeType Type;
|
||||||
public string Path;
|
public string Path;
|
||||||
public string MovedPath;
|
public string MovedToPath;
|
||||||
public DateTime Timestamp;
|
public DateTime Timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -393,10 +393,6 @@ namespace SparkleShare {
|
||||||
foreach (SparkleChangeSet change_set in activity_day) {
|
foreach (SparkleChangeSet change_set in activity_day) {
|
||||||
string event_entry = "<dl>";
|
string event_entry = "<dl>";
|
||||||
|
|
||||||
if (change_set.IsMagical) {
|
|
||||||
event_entry += "<dd>Did something magical</dd>";
|
|
||||||
|
|
||||||
} else {
|
|
||||||
foreach (SparkleChange change in change_set.Changes) {
|
foreach (SparkleChange change in change_set.Changes) {
|
||||||
if (change.Type != SparkleChangeType.Moved) {
|
if (change.Type != SparkleChangeType.Moved) {
|
||||||
|
|
||||||
|
@ -411,12 +407,11 @@ namespace SparkleShare {
|
||||||
event_entry += FormatBreadCrumbs (change_set.Folder.FullPath, change.Path);
|
event_entry += FormatBreadCrumbs (change_set.Folder.FullPath, change.Path);
|
||||||
event_entry += "<br>";
|
event_entry += "<br>";
|
||||||
event_entry += "<small>" + change.Timestamp.ToString ("HH:mm") +"</small> ";
|
event_entry += "<small>" + change.Timestamp.ToString ("HH:mm") +"</small> ";
|
||||||
event_entry += FormatBreadCrumbs (change_set.Folder.FullPath, change.MovedPath);
|
event_entry += FormatBreadCrumbs (change_set.Folder.FullPath, change.MovedToPath);
|
||||||
event_entry += "</dd>";
|
event_entry += "</dd>";
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
string change_set_avatar = GetAvatar (change_set.User.Email, 48);
|
string change_set_avatar = GetAvatar (change_set.User.Email, 48);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue