docs: update git docstrings

Ayman Bagabas created

Change summary

pkg/git/errors.go | 5 ++++-
pkg/git/patch.go  | 5 +++++
pkg/git/tree.go   | 3 ++-
3 files changed, 11 insertions(+), 2 deletions(-)

Detailed changes

pkg/git/errors.go 🔗

@@ -3,7 +3,10 @@ package git
 import "errors"
 
 var (
-	ErrFileNotFound      = errors.New("file not found")
+	// ErrFileNotFound is returned when a file is not found.
+	ErrFileNotFound = errors.New("file not found")
+	// ErrDirectoryNotFound is returned when a directory is not found.
 	ErrDirectoryNotFound = errors.New("directory not found")
+	// ErrReferenceNotFound is returned when a reference is not found.
 	ErrReferenceNotFound = errors.New("reference not found")
 )

pkg/git/patch.go 🔗

@@ -91,24 +91,29 @@ type DiffFile struct {
 	Sections []*DiffSection
 }
 
+// DiffFileChange represents a file diff.
 type DiffFileChange struct {
 	hash string
 	name string
 	mode git.EntryMode
 }
 
+// Hash returns the diff file hash.
 func (f *DiffFileChange) Hash() string {
 	return f.hash
 }
 
+// Name returns the diff name.
 func (f *DiffFileChange) Name() string {
 	return f.name
 }
 
+// Mode returns the diff file mode.
 func (f *DiffFileChange) Mode() git.EntryMode {
 	return f.mode
 }
 
+// Files returns the diff files.
 func (f *DiffFile) Files() (from *DiffFileChange, to *DiffFileChange) {
 	if f.OldIndex != ZeroHash.String() {
 		from = &DiffFileChange{

pkg/git/tree.go 🔗

@@ -24,7 +24,7 @@ type TreeEntry struct {
 	path string
 }
 
-// Entries is a wrapper around git.Entries
+// Entries is a wrapper around git.Entries.
 type Entries []*TreeEntry
 
 var sorters = []func(t1, t2 *TreeEntry) bool{
@@ -107,6 +107,7 @@ func (t *Tree) Entries() (Entries, error) {
 	return ret, nil
 }
 
+// TreeEntry returns the TreeEntry for the file path.
 func (t *Tree) TreeEntry(path string) (*TreeEntry, error) {
 	entry, err := t.Tree.TreeEntry(path)
 	if err != nil {