MCPcopy Index your code
hub / github.com/go-git/go-git / ForEach

Method ForEach

plumbing/object/tree.go:623–636  ·  view source on GitHub ↗

ForEach call the cb function for each tree contained on this iter until an error happens or the end of the iter is reached. If ErrStop is sent the iteration is stop but no error is returned. The iterator is closed.

(cb func(*Tree) error)

Source from the content-addressed store, hash-verified

621// an error happens or the end of the iter is reached. If ErrStop is sent
622// the iteration is stop but no error is returned. The iterator is closed.
623func (iter *TreeIter) ForEach(cb func(*Tree) error) error {
624 return iter.EncodedObjectIter.ForEach(func(obj plumbing.EncodedObject) error {
625 if obj.Type() != plumbing.TreeObject {
626 return nil
627 }
628
629 t, err := DecodeTree(iter.s, obj)
630 if err != nil {
631 return err
632 }
633
634 return cb(t)
635 })
636}
637
638func simpleJoin(parent, child string) string {
639 if len(parent) > 0 {

Callers 1

TestTreeIterMethod · 0.95

Calls 3

DecodeTreeFunction · 0.85
ForEachMethod · 0.65
TypeMethod · 0.65

Tested by 1

TestTreeIterMethod · 0.76