aboutsummaryrefslogtreecommitdiffstats
path: root/blame.go
diff options
context:
space:
mode:
authorShane Da Silva <shanemichaeldasilva@gmail.com>2018-03-27 17:55:08 -0700
committerShane Da Silva <shanemichaeldasilva@gmail.com>2018-03-27 17:55:08 -0700
commita3cf1237f57399759c79b0b1827724d3481c8a9e (patch)
tree0e73903d0170815d2bc5c7774b253a7ceb0b478d /blame.go
parent160e6d5b654fbbaf0d9264f226c56a03f0e27d30 (diff)
downloadgo-git-a3cf1237f57399759c79b0b1827724d3481c8a9e.tar.gz
Add commit hash to blame result
Signed-off-by: Shane Da Silva <shanemichaeldasilva@gmail.com>
Diffstat (limited to 'blame.go')
-rw-r--r--blame.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/blame.go b/blame.go
index 3c5840f..349cdd9 100644
--- a/blame.go
+++ b/blame.go
@@ -109,12 +109,15 @@ type Line struct {
Text string
// Date is when the original text of the line was introduced
Date time.Time
+ // Hash is the commit hash that introduced the original line
+ Hash plumbing.Hash
}
-func newLine(author, text string, date time.Time) *Line {
+func newLine(author, text string, date time.Time, hash plumbing.Hash) *Line {
return &Line{
Author: author,
Text: text,
+ Hash: hash,
Date: date,
}
}
@@ -125,7 +128,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], commits[i].Author.When)
+ l := newLine(commits[i].Author.Email, contents[i], commits[i].Author.When, commits[i].Hash)
result = append(result, l)
}
return result, nil