Skip to content

Commit

Permalink
docs: update git docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Apr 7, 2022
1 parent 0a26b94 commit 8af7f43
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion pkg/git/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)
5 changes: 5 additions & 0 deletions pkg/git/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
3 changes: 2 additions & 1 deletion pkg/git/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 8af7f43

Please sign in to comment.