MCPcopy Create free account
hub / github.com/go-git/go-git / ForEach

Method ForEach

plumbing/object/tree.go:537–550  ·  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

535// an error happens or the end of the iter is reached. If ErrStop is sent
536// the iteration is stop but no error is returned. The iterator is closed.
537func (iter *TreeIter) ForEach(cb func(*Tree) error) error {
538 return iter.EncodedObjectIter.ForEach(func(obj plumbing.EncodedObject) error {
539 if obj.Type() != plumbing.TreeObject {
540 return nil
541 }
542
543 t, err := DecodeTree(iter.s, obj)
544 if err != nil {
545 return err
546 }
547
548 return cb(t)
549 })
550}
551
552func simpleJoin(parent, child string) string {
553 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