diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2017-02-08 11:45:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-08 11:45:07 +0100 |
commit | b65d94e70ea1d013f43234522fa092168e4f1041 (patch) | |
tree | b36da73bd512d1b0ac52e4174ed8b7ed22c75b25 /plumbing/object/file.go | |
parent | 431af32445562b389397f3ee7af90bf61455fff1 (diff) | |
parent | 84b6bd8c22c8683479881a67db03dfdeeeb299ce (diff) | |
download | go-git-b65d94e70ea1d013f43234522fa092168e4f1041.tar.gz |
Merge pull request #259 from smola/docs
Improve documentation
Diffstat (limited to 'plumbing/object/file.go')
-rw-r--r-- | plumbing/object/file.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/plumbing/object/file.go b/plumbing/object/file.go index 618cea7..35e7f24 100644 --- a/plumbing/object/file.go +++ b/plumbing/object/file.go @@ -12,8 +12,12 @@ import ( // File represents git file objects. type File struct { + // Name is the path of the file. It might be relative to a tree, + // depending of the function that generates it. Name string + // Mode is the file mode. Mode os.FileMode + // Blob with the contents of the file. Blob } @@ -56,15 +60,20 @@ func (f *File) Lines() ([]string, error) { return splits, nil } +// FileIter provides an iterator for the files in a tree. type FileIter struct { s storer.EncodedObjectStorer w TreeWalker } +// NewFileIter takes a storer.EncodedObjectStorer and a Tree and returns a +// *FileIter that iterates over all files contained in the tree, recursively. func NewFileIter(s storer.EncodedObjectStorer, t *Tree) *FileIter { return &FileIter{s: s, w: *NewTreeWalker(t, true)} } +// Next moves the iterator to the next file and returns a pointer to it. If +// there are no more files, it returns io.EOF. func (iter *FileIter) Next() (*File, error) { for { name, entry, err := iter.w.Next() |