diff options
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() |