diff --git a/pkg/git/errors.go b/pkg/git/errors.go index 9f8b705d7..b5d5e0674 100644 --- a/pkg/git/errors.go +++ b/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") ) diff --git a/pkg/git/patch.go b/pkg/git/patch.go index f2f3e1cc4..114137090 100644 --- a/pkg/git/patch.go +++ b/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{ diff --git a/pkg/git/tree.go b/pkg/git/tree.go index 517c9effb..c69e3391a 100644 --- a/pkg/git/tree.go +++ b/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 {