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

blame: Add blame line data #754

Merged
merged 1 commit into from
Feb 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions blame.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"strconv"
"strings"
"time"
"unicode/utf8"

"gopkg.in/src-d/go-git.v4/plumbing"
Expand Down Expand Up @@ -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,
}
}

Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions blame_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down