diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2016-03-08 23:30:52 +0100 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2016-03-08 23:30:52 +0100 |
commit | b35fc295b4ac531adc72fc83f2af628c7c163c0e (patch) | |
tree | 0282f20de8279db354233d1d67e3743e08509020 /tree.go | |
parent | 9c9cdff966cc181296f400769d3c8596f17e743a (diff) | |
parent | 9e6a03b7956464ccd9d2fbacedd8e5cc23572d02 (diff) | |
download | go-git-b35fc295b4ac531adc72fc83f2af628c7c163c0e.tar.gz |
Merge pull request #39 from scjalliance/git-object-interface
Added Object interface for Commit, Tree, Blob and Tag
Diffstat (limited to 'tree.go')
-rw-r--r-- | tree.go | 20 |
1 files changed, 15 insertions, 5 deletions
@@ -127,6 +127,19 @@ func (t *Tree) Files() *FileIter { return NewFileIter(t.r, t) } +// ID returns the object ID of the tree. The returned value will always match +// the current value of Tree.Hash. +// +// ID is present to fufill the Object interface. +func (t *Tree) ID() core.Hash { + return t.Hash +} + +// Type returns the type of object. It always returns core.TreeObject. +func (t *Tree) Type() core.ObjectType { + return core.TreeObject +} + // Decode transform an core.Object into a Tree struct func (t *Tree) Decode(o core.Object) (err error) { if o.Type() != core.TreeObject { @@ -229,12 +242,9 @@ func (iter *TreeIter) Next() (*Tree, error) { return nil, err } - if obj.Type() != core.TreeObject { - // Skip non-tree objects - continue + if tree, ok := obj.(*Tree); ok { + return tree, nil } - - return iter.w.Tree(), nil } } |