private BlameCommit ParseCommitInfo(Dictionary <Hash, BlameCommit> cache) { Assert.IsNotNull(cache); var hash = ReadHash(); SkipLine(); if (cache.TryGetValue(hash, out var commit)) { return(commit); } var author = ReadStringValue(AuthorHeader); var authorMail = ReadStringValue(AuthorMailHeader); var authorTime = ReadDateValue(AuthorTimeHeader); var authorTZ = ReadStringValue(AuthorTimeZoneHeader); var committer = ReadStringValue(CommitterHeader); var committerMail = ReadStringValue(CommitterMailHeader); var committerTime = ReadDateValue(CommitterTimeHeader); var committerTZ = ReadStringValue(CommitterTimeZoneHeader); var summary = ReadStringValue(SummaryHeader); var isBoundary = ReadBoundaryValue(); /* optional */ var previous = ReadPreviousValue(); /* optional */ var fileName = ReadStringValue(FileNameHeader); commit = new BlameCommit(hash, author, authorMail, authorTime, authorTZ, committer, committerMail, committerTime, committerTZ, summary, isBoundary, previous); cache.Add(hash, commit); return(commit); }
public BlameLine(BlameCommit commit, int number, string text, string ending = LineEnding.Lf) { Verify.Argument.IsNotNull(commit, "commit"); Verify.Argument.IsNotNull(text, "text"); _commit = commit; _text = text; _ending = ending; _number = number; _charPositions = -1; }
public BlameLine(BlameCommit commit, int number, string text, string ending = LineEnding.Lf) { Verify.Argument.IsNotNull(commit, nameof(commit)); Verify.Argument.IsNotNull(text, nameof(text)); Commit = commit; Text = text; Ending = ending; Number = number; _charPositions = -1; }
public BlameFile ParseBlameFile(string fileName) { var cache = new Dictionary <Hash, BlameCommit>(Hash.EqualityComparer); int lineN = 1; BlameCommit prev = null; var hunks = new List <BlameHunk>(); var lines = new List <BlameLine>(); while (!IsAtEndOfString) { var commit = ParseCommitInfo(cache); Skip(); if (IsAtEndOfString) { break; } int eol = FindLfLineEnding(); string ending; if (String[eol - 1] == '\r') { --eol; ending = LineEnding.CrLf; } else { ending = LineEnding.Lf; } var line = new BlameLine(commit, lineN++, ReadStringUpTo(eol, ending.Length), ending); if (commit != prev) { if (lines.Count != 0) { hunks.Add(new BlameHunk(prev, lines)); lines.Clear(); } } lines.Add(line); prev = commit; } if (lines.Count != 0) { hunks.Add(new BlameHunk(prev, lines)); lines.Clear(); } return(new BlameFile(fileName, hunks)); }
private BlameCommit ParseCommitInfo(Dictionary<Hash, BlameCommit> cache) { Assert.IsNotNull(cache); var hash = ReadHash(); SkipLine(); BlameCommit commit; if(cache.TryGetValue(hash, out commit)) { return commit; } var author = ReadStringValue(AuthorHeader); var authorMail = ReadStringValue(AuthorMailHeader); var authorTime = ReadDateValue(AuthorTimeHeader); var authorTZ = ReadStringValue(AuthorTimeZoneHeader); var committer = ReadStringValue(CommitterHeader); var committerMail = ReadStringValue(CommitterMailHeader); var committerTime = ReadDateValue(CommitterTimeHeader); var committerTZ = ReadStringValue(CommitterTimeZoneHeader); var summary = ReadStringValue(SummaryHeader); var isBoundary = ReadBoundaryValue(); /* optional */ var previous = ReadPreviousValue(); /* optional */ var fileName = ReadStringValue(FileNameHeader); commit = new BlameCommit(hash, author, authorMail, authorTime, authorTZ, committer, committerMail, committerTime, committerTZ, summary, isBoundary, previous); cache.Add(hash, commit); return commit; }