diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2016-08-15 23:09:33 +0200 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2016-08-15 23:09:33 +0200 |
commit | 6b9a59be60de5b66aee14e9160ace80734008eca (patch) | |
tree | c302776360b0fd4f774f67f177870fda478b4258 /commit.go | |
parent | ed2e3b299e03e4bfd4c37bf5232e9fde05c0600d (diff) | |
download | go-git-6b9a59be60de5b66aee14e9160ace80734008eca.tar.gz |
core: *Iter.ForEach method
Diffstat (limited to 'commit.go')
-rw-r--r-- | commit.go | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -154,6 +154,20 @@ func (iter *CommitIter) Next() (*Commit, error) { return commit, commit.Decode(obj) } +// ForEach call the cb function for each commit contained on this iter until +// an error happends or the end of the iter is reached. If ErrStop is sent +// the iteration is stop but no error is returned +func (iter *CommitIter) ForEach(cb func(*Commit) error) error { + return iter.ObjectIter.ForEach(func(obj core.Object) error { + commit := &Commit{r: iter.r} + if err := commit.Decode(obj); err != nil { + return err + } + + return cb(commit) + }) +} + type commitSorterer struct { l []*Commit } |