Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit 721449a

Browse files
authored
Merge pull request #754 from shanedasilva/add_blame_line_data
blame: Add blame line data
2 parents 3f00f5f + 0c19e6b commit 721449a

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

blame.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"strconv"
88
"strings"
9+
"time"
910
"unicode/utf8"
1011

1112
"gopkg.in/src-d/go-git.v4/plumbing"
@@ -106,12 +107,15 @@ type Line struct {
106107
Author string
107108
// Text is the original text of the line.
108109
Text string
110+
// Date is when the original text of the line was introduced
111+
Date time.Time
109112
}
110113

111-
func newLine(author, text string) *Line {
114+
func newLine(author, text string, date time.Time) *Line {
112115
return &Line{
113116
Author: author,
114117
Text: text,
118+
Date: date,
115119
}
116120
}
117121

@@ -121,7 +125,7 @@ func newLines(contents []string, commits []*object.Commit) ([]*Line, error) {
121125
}
122126
result := make([]*Line, 0, len(contents))
123127
for i := range contents {
124-
l := newLine(commits[i].Author.Email, contents[i])
128+
l := newLine(commits[i].Author.Email, contents[i], commits[i].Author.When)
125129
result = append(result, l)
126130
}
127131
return result, nil

blame_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ func (s *BlameSuite) mockBlame(c *C, t blameTest, r *Repository) (blame *BlameRe
5353
l := &Line{
5454
Author: commit.Author.Email,
5555
Text: lines[i],
56+
Date: commit.Author.When,
5657
}
5758
blamedLines = append(blamedLines, l)
5859
}

0 commit comments

Comments
 (0)