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

Commit 9006915

Browse files
committed
improve git package documentation (fix #231)
1 parent d105e15 commit 9006915

File tree

3 files changed

+24
-21
lines changed

3 files changed

+24
-21
lines changed

blame.go

+15-15
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,21 @@ import (
1313
"srcd.works/go-git.v4/utils/diff"
1414
)
1515

16+
// BlameResult represents the result of a Blame operation
1617
type BlameResult struct {
17-
Path string
18-
Rev plumbing.Hash
18+
// Path is the path of the File that we're blaming
19+
Path string
20+
// Rev is the hash of the specified Commit used to generate this result
21+
Rev plumbing.Hash
22+
// Lines contains every line with its authorship
1923
Lines []*Line
2024
}
2125

22-
// Blame returns the last commit that modified each line of a file in a
23-
// repository.
24-
//
25-
// The file to blame is identified by the input arguments: repo, commit and path.
26-
// The output is a slice of commits, one for each line in the file.
26+
// Blame returns a BlameResult that contains all the data needed to know the
27+
// last author of each line of an specified file starting the history from
28+
// a specified commit. The file to blame is identified by the input arguments:
29+
// commit and path. commit is a Commit object obtained from a Repository. Path
30+
// represents a path to a specific file contained into the repository.
2731
//
2832
// Blaming a file is a two step process:
2933
//
@@ -33,12 +37,6 @@ type BlameResult struct {
3337
// 2. Then build a graph with a node for every line in every file in
3438
// the history of the file.
3539
//
36-
// Each node (line) holds the commit where it was introduced or
37-
// last modified. To achieve that we use the FORWARD algorithm
38-
// described in Zimmermann, et al. "Mining Version Archives for
39-
// Co-changed Lines", in proceedings of the Mining Software
40-
// Repositories workshop, Shanghai, May 22-23, 2006.
41-
//
4240
// Each node is assigned a commit: Start by the nodes in the first
4341
// commit. Assign that commit as the creator of all its lines.
4442
//
@@ -98,8 +96,10 @@ func Blame(c *object.Commit, path string) (*BlameResult, error) {
9896

9997
// Line values represent the contents and author of a line in BlamedResult values.
10098
type Line struct {
101-
Author string // email address of the author of the line.
102-
Text string // original text of the line.
99+
// Author is the email address of the last author that modified the line
100+
Author string
101+
// Text is the original text of the line.
102+
Text string
103103
}
104104

105105
func newLine(author, text string) *Line {

references.go

+8-5
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,18 @@ import (
1010
"github.com/sergi/go-diff/diffmatchpatch"
1111
)
1212

13-
// References returns a References for the file at "path", the commits are
14-
// sorted in commit order. It stops searching a branch for a file upon reaching
15-
// the commit were the file was created.
13+
// References returns a slice of Commits for the file at "path", starting from
14+
// the commit provided that contains the file from the provided path. The last
15+
// commit into the returned slice is the commit where the file was created.
16+
// If the provided commit does not contains the specified path, a nil slice is
17+
// returned. The commits are sorted in commit order, newer to older.
1618
//
1719
// Caveats:
20+
//
1821
// - Moves and copies are not currently supported.
22+
//
1923
// - Cherry-picks are not detected unless there are no commits between them and
20-
// therefore can appear repeated in the list.
21-
// (see git path-id for hints on how to fix this).
24+
// therefore can appear repeated in the list. (see git path-id for hints on how to fix this).
2225
func References(c *object.Commit, path string) ([]*object.Commit, error) {
2326
var result []*object.Commit
2427
seen := make(map[plumbing.Hash]struct{}, 0)

remote.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func newRemote(s storage.Storer, c *config.RemoteConfig) *Remote {
3232
return &Remote{s: s, c: c}
3333
}
3434

35-
// Config return the config
35+
// Config returns the RemoteConfig object used to instantiate this Remote
3636
func (r *Remote) Config() *config.RemoteConfig {
3737
return r.c
3838
}

0 commit comments

Comments
 (0)