mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 20:24:59 +00:00
refactor<Blame>: new blame tool
This commit is contained in:
parent
697879b6a5
commit
a1bfbfe02e
5 changed files with 121 additions and 123 deletions
|
@ -9,6 +9,8 @@ namespace SourceGit.Commands {
|
|||
public class Blame : Command {
|
||||
private static readonly Regex REG_FORMAT = new Regex(@"^\^?([0-9a-f]+)\s+.*\((.*)\s+(\d+)\s+[\-\+]?\d+\s+\d+\) (.*)");
|
||||
private Data data = new Data();
|
||||
private bool needUnifyCommitSHA = false;
|
||||
private int minSHALen = 0;
|
||||
|
||||
public class Data {
|
||||
public List<Models.BlameLine> Lines = new List<Models.BlameLine>();
|
||||
|
@ -22,6 +24,15 @@ namespace SourceGit.Commands {
|
|||
|
||||
public Data Result() {
|
||||
Exec();
|
||||
|
||||
if (needUnifyCommitSHA) {
|
||||
foreach (var line in data.Lines) {
|
||||
if (line.CommitSHA.Length > minSHALen) {
|
||||
line.CommitSHA = line.CommitSHA.Substring(0, minSHALen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
@ -52,6 +63,12 @@ namespace SourceGit.Commands {
|
|||
Content = content,
|
||||
};
|
||||
|
||||
if (line[0] == '^') {
|
||||
needUnifyCommitSHA = true;
|
||||
if (minSHALen == 0) minSHALen = commit.Length;
|
||||
else if (commit.Length < minSHALen) minSHALen = commit.Length;
|
||||
}
|
||||
|
||||
data.Lines.Add(blameLine);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue