Skip to content

Commit 3507129

Browse files
committed
Merge branch 'master' into instant-display
Conflicts: lib/controllers/blameViewController.js lib/views/blame-line-view.coffee
2 parents 4b81f22 + 3971405 commit 3507129

File tree

2 files changed

+34
-7
lines changed

2 files changed

+34
-7
lines changed

lib/util/blameFormatter.js

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ function parseDate(line) {
3636
return moment.unix(dateStamp).format(formatString);
3737
}
3838

39+
/**
40+
* Parses the summary line from the blame data for a line of code
41+
*
42+
* @param {string} line - the blame data for a particular line of code
43+
* @return {string} - the summary line for the last commit for a line of code
44+
*/
45+
function parseSummary(line) {
46+
var summaryMatcher = /^summary\s(.*)$/m;
47+
return line.match(summaryMatcher)[1];
48+
}
49+
3950
/**
4051
* Parses the blame --porcelain output for a particular line of code into a
4152
* usable object with properties:
@@ -44,6 +55,7 @@ function parseDate(line) {
4455
* line: the line number (1 indexed)
4556
* committer: name of the committer of that line
4657
* date: the date of the commit
58+
* summary: the summary of the commit
4759
*
4860
* @param {string} blameData - the blame --porcelain output for a line of code
4961
* @param {number} index - the index that the data appeared in an array of line
@@ -55,7 +67,8 @@ function parseBlameLine(blameData, index) {
5567
hash: parseRevision(blameData),
5668
line: index + 1,
5769
committer: parseCommitter(blameData),
58-
date: parseDate(blameData)
70+
date: parseDate(blameData),
71+
summary: parseSummary(blameData)
5972
});
6073
}
6174

@@ -78,14 +91,18 @@ function markIfNoCommit(parsedBlame) {
7891
* @param {string} blameOutput - output from 'git blame --porcelain <file>'
7992
*/
8093
function parseBlameOutput(blameOut) {
81-
// Matches new lines only when followed by a line with commit hash info that
82-
// are followed by autor line. This is the 1st and 2nd line of the blame
83-
// --porcelain output.
84-
var singleLineDataSplitRegex = /\n(?=\w+\s(?:\d+\s)+\d+\nauthor)/g;
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;
8597

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

91108
// EXPORTS

lib/views/blame-line-view.coffee

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{React, Reactionary} = require 'atom'
1+
{$, React, Reactionary} = require 'atom'
22
RP = React.PropTypes
33
{div, span, a} = Reactionary
44
RemoteRevision = require '../util/RemoteRevision'
@@ -38,6 +38,16 @@ BlameLineComponent = React.createClass
3838
span className: 'committer text-highlight',
3939
@props.committer.split(' ').slice(-1)[0]
4040

41+
componentDidMount: ->
42+
$el = $(@getDOMNode())
43+
if @props.summary
44+
$el.setTooltip
45+
title: @props.summary
46+
placement: "auto left"
47+
48+
componentWillUnmount: ->
49+
$(@getDOMNode()).tooltip "destroy"
50+
4151
shouldComponentUpdate: ->
4252
false
4353

0 commit comments

Comments
 (0)