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

Method ForEach

plumbing/object/object.go:207–220  ·  view source on GitHub ↗

ForEach call the cb function for each object 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(Object) error)

Source from the content-addressed store, hash-verified

205// an error happens or the end of the iter is reached. If ErrStop is sent
206// the iteration is stop but no error is returned. The iterator is closed.
207func (iter *ObjectIter) ForEach(cb func(Object) error) error {
208 return iter.EncodedObjectIter.ForEach(func(obj plumbing.EncodedObject) error {
209 o, err := iter.toObject(obj)
210 if err == plumbing.ErrInvalidType {
211 return nil
212 }
213
214 if err != nil {
215 return err
216 }
217
218 return cb(o)
219 })
220}
221
222func (iter *ObjectIter) toObject(obj plumbing.EncodedObject) (Object, error) {
223 switch obj.Type() {

Callers 1

TestObjectIterMethod · 0.95

Calls 2

toObjectMethod · 0.95
ForEachMethod · 0.65

Tested by 1

TestObjectIterMethod · 0.76