blob: 7f4a0562220fa110c8679a569a7e7ffb467db584 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
package gitpipe
import "gitlab.com/gitlab-org/gitaly/v14/internal/git"
// CatfileObjectIterator is an iterator returned by the Revlist function.
type CatfileObjectIterator interface {
ObjectIterator
// Result returns the current item.
Result() CatfileObjectResult
}
// NewCatfileObjectIterator returns a new CatfileObjectIterator for the given items.
func NewCatfileObjectIterator(items []CatfileObjectResult) CatfileObjectIterator {
itemChan := make(chan CatfileObjectResult, len(items))
for _, item := range items {
itemChan <- item
}
close(itemChan)
return &catfileObjectIterator{
ch: itemChan,
}
}
type catfileObjectIterator struct {
ch <-chan CatfileObjectResult
result CatfileObjectResult
}
func (it *catfileObjectIterator) Next() bool {
if it.result.err != nil {
return false
}
var ok bool
it.result, ok = <-it.ch
if !ok || it.result.err != nil {
return false
}
return true
}
func (it *catfileObjectIterator) Err() error {
return it.result.err
}
func (it *catfileObjectIterator) Result() CatfileObjectResult {
return it.result
}
func (it *catfileObjectIterator) ObjectID() git.ObjectID {
return it.result.ObjectInfo.Oid
}
func (it *catfileObjectIterator) ObjectName() []byte {
return it.result.ObjectName
}
|