()
| 42 | } |
| 43 | |
| 44 | func (w *commitPreIterator) Next() (*Commit, error) { |
| 45 | var c *Commit |
| 46 | for { |
| 47 | if w.start != nil { |
| 48 | c = w.start |
| 49 | w.start = nil |
| 50 | } else { |
| 51 | current := len(w.stack) - 1 |
| 52 | if current < 0 { |
| 53 | return nil, io.EOF |
| 54 | } |
| 55 | |
| 56 | var err error |
| 57 | c, err = w.stack[current].Next() |
| 58 | if err == io.EOF { |
| 59 | w.stack = w.stack[:current] |
| 60 | continue |
| 61 | } |
| 62 | |
| 63 | if err != nil { |
| 64 | return nil, err |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | if w.seen[c.Hash] || w.seenExternal[c.Hash] { |
| 69 | continue |
| 70 | } |
| 71 | |
| 72 | w.seen[c.Hash] = true |
| 73 | |
| 74 | if c.NumParents() > 0 { |
| 75 | w.stack = append(w.stack, filteredParentIter(c, w.seen)) |
| 76 | } |
| 77 | |
| 78 | return c, nil |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | func filteredParentIter(c *Commit, seen map[plumbing.Hash]bool) CommitIter { |
| 83 | var hashes []plumbing.Hash |
no test coverage detected