mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 12:45:00 +00:00
refactor: commits only hold the end position of subject in body
This commit is contained in:
parent
064d04fccc
commit
b4e01a8b93
8 changed files with 27 additions and 41 deletions
|
@ -57,17 +57,18 @@ namespace SourceGit.Commands
|
|||
if (line.Equals(_endOfBodyToken, StringComparison.Ordinal))
|
||||
{
|
||||
_nextPartIdx = 0;
|
||||
_current.Message = _messageReader.ToString().Trim();
|
||||
_messageReader.Clear();
|
||||
}
|
||||
else if (!_isSubjectSet)
|
||||
{
|
||||
_isSubjectSet = true;
|
||||
_current.Subject = line;
|
||||
_current.Body = _bodyReader.ToString().TrimEnd();
|
||||
_bodyReader.Clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
_messageReader.AppendLine(line);
|
||||
if (!_isSubjectSet)
|
||||
{
|
||||
_isSubjectSet = true;
|
||||
_current.SubjectLen = line.Length;
|
||||
}
|
||||
|
||||
_bodyReader.AppendLine(line);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -191,9 +192,9 @@ namespace SourceGit.Commands
|
|||
private List<Models.Commit> _commits = new List<Models.Commit>();
|
||||
private Models.Commit _current = null;
|
||||
private bool _isHeadFounded = false;
|
||||
private readonly bool _findFirstMerged = true;
|
||||
private bool _findFirstMerged = true;
|
||||
private int _nextPartIdx = 0;
|
||||
private bool _isSubjectSet = false;
|
||||
private StringBuilder _messageReader = new StringBuilder();
|
||||
private StringBuilder _bodyReader = new StringBuilder();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,15 +32,12 @@ namespace SourceGit.Commands
|
|||
commit.AuthorTime = ulong.Parse(lines[4]);
|
||||
commit.Committer = Models.User.FindOrAdd(lines[5]);
|
||||
commit.CommitterTime = ulong.Parse(lines[6]);
|
||||
commit.Subject = lines[7];
|
||||
commit.SubjectLen = lines[7].Length;
|
||||
|
||||
if (lines.Length > 8)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (int i = 8; i < lines.Length; i++)
|
||||
builder.Append(lines[i]);
|
||||
commit.Message = builder.ToString();
|
||||
}
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (int i = 7; i < lines.Length; i++)
|
||||
builder.AppendLine(lines[i]);
|
||||
commit.Body = builder.ToString().TrimEnd();
|
||||
|
||||
return commit;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue