8af7f43fe460329f246ce32ef69a5b80d407f39a

Author
Ayman Bagabas <ayman.bagabas@gmail.com>
Committer
Ayman Bagabas <ayman.bagabas@gmail.com>
Date

Message

docs: update git docstrings

Diff

 1diff --git a/pkg/git/errors.go b/pkg/git/errors.go
 2index 9f8b705d77c864e5cdae5adc760c12ce1955ccd9..b5d5e0674f77ce4fb1284699bc1b69b0d3377743 100644
 3--- a/pkg/git/errors.go
 4+++ b/pkg/git/errors.go
 5@@ -3,7 +3,10 @@ package git
 6 import "errors"
 7 
 8 var (
 9-	ErrFileNotFound      = errors.New("file not found")
10+	// ErrFileNotFound is returned when a file is not found.
11+	ErrFileNotFound = errors.New("file not found")
12+	// ErrDirectoryNotFound is returned when a directory is not found.
13 	ErrDirectoryNotFound = errors.New("directory not found")
14+	// ErrReferenceNotFound is returned when a reference is not found.
15 	ErrReferenceNotFound = errors.New("reference not found")
16 )
17diff --git a/pkg/git/patch.go b/pkg/git/patch.go
18index f2f3e1cc4b3008a7402e5f6759fe5c88747b8311..114137090bae4584c49989981dadd9d97bf1c791 100644
19--- a/pkg/git/patch.go
20+++ b/pkg/git/patch.go
21@@ -91,24 +91,29 @@ type DiffFile struct {
22 	Sections []*DiffSection
23 }
24 
25+// DiffFileChange represents a file diff.
26 type DiffFileChange struct {
27 	hash string
28 	name string
29 	mode git.EntryMode
30 }
31 
32+// Hash returns the diff file hash.
33 func (f *DiffFileChange) Hash() string {
34 	return f.hash
35 }
36 
37+// Name returns the diff name.
38 func (f *DiffFileChange) Name() string {
39 	return f.name
40 }
41 
42+// Mode returns the diff file mode.
43 func (f *DiffFileChange) Mode() git.EntryMode {
44 	return f.mode
45 }
46 
47+// Files returns the diff files.
48 func (f *DiffFile) Files() (from *DiffFileChange, to *DiffFileChange) {
49 	if f.OldIndex != ZeroHash.String() {
50 		from = &DiffFileChange{
51diff --git a/pkg/git/tree.go b/pkg/git/tree.go
52index 517c9effb9ea6df86b1c80b7003837a52a190365..c69e3391a01ce5b2436c5db45eab6d84df4fff6d 100644
53--- a/pkg/git/tree.go
54+++ b/pkg/git/tree.go
55@@ -24,7 +24,7 @@ type TreeEntry struct {
56 	path string
57 }
58 
59-// Entries is a wrapper around git.Entries
60+// Entries is a wrapper around git.Entries.
61 type Entries []*TreeEntry
62 
63 var sorters = []func(t1, t2 *TreeEntry) bool{
64@@ -107,6 +107,7 @@ func (t *Tree) Entries() (Entries, error) {
65 	return ret, nil
66 }
67 
68+// TreeEntry returns the TreeEntry for the file path.
69 func (t *Tree) TreeEntry(path string) (*TreeEntry, error) {
70 	entry, err := t.Tree.TreeEntry(path)
71 	if err != nil {