Skip to content

Commit b51008e

Browse files
committed
Fixes Issue #27 last line of blame doesnt appear
1 parent c3ea635 commit b51008e

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

lib/util/blameFormatter.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,14 @@ function markIfNoCommit(parsedBlame) {
9191
* @param {string} blameOutput - output from 'git blame --porcelain <file>'
9292
*/
9393
function parseBlameOutput(blameOut) {
94-
// Matches the info lines for a specific line in the blame --porcelain output,
95-
// which is up to the line after the one that begins with filename.
96-
var blameChunkRegex = /(?:.*\n)*?filename .*?\n\t.*?\n/g;
94+
// Matches new lines only when followed by a line with commit hash info that
95+
// are followed by autor line. This is the 1st and 2nd line of the blame
96+
// --porcelain output.
97+
var singleLineDataSplitRegex = /\n(?=\w+\s(?:\d+\s)+\d+\nauthor)/g;
9798

9899
// Split the blame output into data for each line and parse out desired
99100
// data from each into an object.
100-
var results = [];
101-
var match;
102-
while ((match = blameChunkRegex.exec(blameOut))) {
103-
results.push(parseBlameLine(match[0]));
104-
}
105-
return results;
101+
return blameOut.split(singleLineDataSplitRegex).map(parseBlameLine);
106102
}
107103

108104
// EXPORTS

0 commit comments

Comments
 (0)