repo git: Simplify log parsing
This commit is contained in:
parent
a33c894b02
commit
c4c933ebf7
|
@ -764,6 +764,7 @@ namespace SparkleLib.Git {
|
|||
string [] lines = output.Split ("\n".ToCharArray ());
|
||||
List<string> entries = new List <string> ();
|
||||
|
||||
// Split up commit entries
|
||||
int line_number = 0;
|
||||
bool first_pass = true;
|
||||
string entry = "", last_entry = "";
|
||||
|
@ -777,8 +778,8 @@ namespace SparkleLib.Git {
|
|||
first_pass = false;
|
||||
}
|
||||
|
||||
// Only parse 250 files to prevent memory issues
|
||||
if (line_number < 254) {
|
||||
// Only parse first 250 files to prevent memory issues
|
||||
if (line_number < 250) {
|
||||
entry += line + "\n";
|
||||
line_number++;
|
||||
}
|
||||
|
@ -788,11 +789,13 @@ namespace SparkleLib.Git {
|
|||
|
||||
entries.Add (last_entry);
|
||||
|
||||
|
||||
// Parse commit entries
|
||||
foreach (string log_entry in entries) {
|
||||
Match match = this.log_regex.Match (log_entry);
|
||||
|
||||
if (match.Success) {
|
||||
if (!match.Success)
|
||||
continue;
|
||||
|
||||
SparkleChangeSet change_set = new SparkleChangeSet ();
|
||||
|
||||
change_set.Folder = new SparkleFolder (Name);
|
||||
|
@ -813,18 +816,20 @@ namespace SparkleLib.Git {
|
|||
|
||||
string [] entry_lines = log_entry.Split ("\n".ToCharArray ());
|
||||
|
||||
// Parse file list. Lines containing file changes start with ":"
|
||||
foreach (string entry_line in entry_lines) {
|
||||
if (entry_line.StartsWith (":")) {
|
||||
if (entry_line.Contains ("\\177"))
|
||||
// Skip lines containing backspace characters
|
||||
if (!entry_line.StartsWith (":") || entry_line.Contains ("\\177"))
|
||||
continue;
|
||||
|
||||
string type_letter = entry_line [37].ToString ();
|
||||
string file_path = entry_line.Substring (39);
|
||||
bool change_is_folder = false;
|
||||
|
||||
if (file_path.Equals (".sparkleshare"))
|
||||
continue;
|
||||
|
||||
string type_letter = entry_line [37].ToString ();
|
||||
bool change_is_folder = false;
|
||||
|
||||
if (file_path.EndsWith (".empty")) {
|
||||
file_path = file_path.Substring (0, file_path.Length - ".empty".Length);
|
||||
change_is_folder = true;
|
||||
|
@ -833,6 +838,13 @@ namespace SparkleLib.Git {
|
|||
file_path = EnsureSpecialCharacters (file_path);
|
||||
file_path = file_path.Replace ("\\\"", "\"");
|
||||
|
||||
SparkleChange change = new SparkleChange () {
|
||||
Path = file_path,
|
||||
IsFolder = change_is_folder,
|
||||
Timestamp = change_set.Timestamp,
|
||||
Type = SparkleChangeType.Added
|
||||
};
|
||||
|
||||
if (type_letter.Equals ("R")) {
|
||||
int tab_pos = entry_line.LastIndexOf ("\t");
|
||||
file_path = entry_line.Substring (42, tab_pos - 42);
|
||||
|
@ -854,38 +866,21 @@ namespace SparkleLib.Git {
|
|||
change_is_folder = true;
|
||||
}
|
||||
|
||||
change_set.Changes.Add (
|
||||
new SparkleChange () {
|
||||
Path = file_path,
|
||||
IsFolder = change_is_folder,
|
||||
MovedToPath = to_file_path,
|
||||
Timestamp = change_set.Timestamp,
|
||||
Type = SparkleChangeType.Moved
|
||||
}
|
||||
);
|
||||
change.Path = file_path;
|
||||
change.MovedToPath = to_file_path;
|
||||
change.Type = SparkleChangeType.Moved;
|
||||
|
||||
} else {
|
||||
SparkleChangeType change_type = SparkleChangeType.Added;
|
||||
|
||||
if (type_letter.Equals ("M")) {
|
||||
change_type = SparkleChangeType.Edited;
|
||||
} else if (type_letter.Equals ("M")) {
|
||||
change.Type = SparkleChangeType.Edited;
|
||||
|
||||
} else if (type_letter.Equals ("D")) {
|
||||
change_type = SparkleChangeType.Deleted;
|
||||
change.Type = SparkleChangeType.Deleted;
|
||||
}
|
||||
|
||||
change_set.Changes.Add (
|
||||
new SparkleChange () {
|
||||
Path = file_path,
|
||||
IsFolder = change_is_folder,
|
||||
Timestamp = change_set.Timestamp,
|
||||
Type = change_type
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
change_set.Changes.Add (change);
|
||||
}
|
||||
|
||||
// Group commits per user, per day
|
||||
if (change_sets.Count > 0 && path == null) {
|
||||
SparkleChangeSet last_change_set = change_sets [change_sets.Count - 1];
|
||||
|
||||
|
@ -910,6 +905,7 @@ namespace SparkleLib.Git {
|
|||
}
|
||||
|
||||
} else {
|
||||
// Don't show removals or moves in the revision list of a file
|
||||
if (path != null) {
|
||||
List<SparkleChange> changes_to_skip = new List<SparkleChange> ();
|
||||
|
||||
|
@ -928,7 +924,6 @@ namespace SparkleLib.Git {
|
|||
change_sets.Add (change_set);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return change_sets;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue