diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2018-02-21 17:21:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-21 17:21:16 +0100 |
commit | 721449aadc2792494d030ac37ee779025a9b2869 (patch) | |
tree | 13d95f57f19e615a0282245b12681f65b0ee6d0d | |
parent | 3f00f5f02f0b2a1beb6d4ad5cac5e2a0f4c13853 (diff) | |
parent | 0c19e6b0cb696005d94e4385303ef8b48376b92f (diff) | |
download | go-git-721449aadc2792494d030ac37ee779025a9b2869.tar.gz |
Merge pull request #754 from shanedasilva/add_blame_line_data
blame: Add blame line data
-rw-r--r-- | blame.go | 8 | ||||
-rw-r--r-- | blame_test.go | 1 |
2 files changed, 7 insertions, 2 deletions
@@ -6,6 +6,7 @@ import ( "fmt" "strconv" "strings" + "time" "unicode/utf8" "gopkg.in/src-d/go-git.v4/plumbing" @@ -106,12 +107,15 @@ type Line struct { Author string // Text is the original text of the line. Text string + // Date is when the original text of the line was introduced + Date time.Time } -func newLine(author, text string) *Line { +func newLine(author, text string, date time.Time) *Line { return &Line{ Author: author, Text: text, + Date: date, } } @@ -121,7 +125,7 @@ func newLines(contents []string, commits []*object.Commit) ([]*Line, error) { } result := make([]*Line, 0, len(contents)) for i := range contents { - l := newLine(commits[i].Author.Email, contents[i]) + l := newLine(commits[i].Author.Email, contents[i], commits[i].Author.When) result = append(result, l) } return result, nil diff --git a/blame_test.go b/blame_test.go index 5374610..51c546a 100644 --- a/blame_test.go +++ b/blame_test.go @@ -53,6 +53,7 @@ func (s *BlameSuite) mockBlame(c *C, t blameTest, r *Repository) (blame *BlameRe l := &Line{ Author: commit.Author.Email, Text: lines[i], + Date: commit.Author.When, } blamedLines = append(blamedLines, l) } |