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

Commit c347e97

Browse files
committed
Extra fixes for #7
1 parent 48bf5bd commit c347e97

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

blame/blame.go

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,9 @@ import (
5050
// assigned the new commit as its origin. Modified lines also get
5151
// this new commit. Untouched lines retain the old commit.
5252
//
53-
// All this work is done in the assignOrigin function.
54-
//
55-
// This function holds all the internal relevant data in a blame
56-
// struct, that is not exported.
53+
// All this work is done in the assignOrigin function which holds all
54+
// the internal relevant data in a "blame" struct, that is not
55+
// exported.
5756
//
5857
// TODO: ways to improve the efficiency of this function:
5958
//
@@ -64,9 +63,9 @@ import (
6463
//
6564
// TODO: ways to improve the function in general:
6665
//
67-
// 1. Add memoization betweenn revlist and assign.
66+
// 1. Add memoization between revlist and assign.
6867
//
69-
// 2. It is using much more memmory than needed, see the TODOs below.
68+
// 2. It is using much more memory than needed, see the TODOs below.
7069

7170
type Blame struct {
7271
Repo string
@@ -126,8 +125,6 @@ func newLine(author, text string) *line {
126125

127126
func newLines(contents []string, commits []*git.Commit) ([]*line, error) {
128127
if len(contents) != len(commits) {
129-
fmt.Println(len(contents))
130-
fmt.Println(len(commits))
131128
return nil, errors.New("contents and commits have different length")
132129
}
133130
result := make([]*line, 0, len(contents))
@@ -149,7 +146,7 @@ type blame struct {
149146
graph [][]*git.Commit // the graph of the lines in the file across all the revisions TODO: not all commits are needed, only the current rev and the prev
150147
}
151148

152-
// calculte the history of a file "path", from commit "from, sorted by commit date.
149+
// calculte the history of a file "path", starting from commit "from", sorted by commit date.
153150
func (b *blame) fillRevs() error {
154151
var err error
155152
b.revs, err = revlist.NewRevs(b.repo, b.fRev, b.path)
@@ -231,8 +228,8 @@ func (b *blame) assignOrigin(c, p int) {
231228
}
232229
}
233230

234-
// PrettyPrint prints the results of a Blame using git-blame's style.
235-
func (b *blame) PrettyPrint() string {
231+
// GoString prints the results of a Blame using git-blame's style.
232+
func (b *blame) GoString() string {
236233
var buf bytes.Buffer
237234

238235
file, err := b.fRev.File(b.path)

revlist/revlist.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,12 @@ func blobHash(path string, commit *git.Commit) (hash core.Hash, found bool) {
175175
return file.Hash, true
176176
}
177177

178+
type contentsComparatorFn func(path string, a, b *git.Commit) (bool, error)
179+
178180
// Returns a new slice of commits, with duplicates removed. Expects a
179181
// sorted commit list. Duplication is defined according to "comp". It
180182
// will always keep the first commit of a series of duplicated commits.
181-
func removeComp(path string, cs []*git.Commit, comp func(string, *git.Commit, *git.Commit) (bool, error)) ([]*git.Commit, error) {
183+
func removeComp(path string, cs []*git.Commit, comp contentsComparatorFn) ([]*git.Commit, error) {
182184
result := make([]*git.Commit, 0, len(cs))
183185
if len(cs) == 0 {
184186
return result, nil
@@ -196,7 +198,7 @@ func removeComp(path string, cs []*git.Commit, comp func(string, *git.Commit, *g
196198
return result, nil
197199
}
198200

199-
// Equivalent commits are commits whos patch is the same.
201+
// Equivalent commits are commits whose patch is the same.
200202
func equivalent(path string, a, b *git.Commit) (bool, error) {
201203
numParentsA := a.NumParents()
202204
numParentsB := b.NumParents()

0 commit comments

Comments
 (0)