File tree Expand file tree Collapse file tree 2 files changed +18
-16
lines changed Expand file tree Collapse file tree 2 files changed +18
-16
lines changed Original file line number Diff line number Diff line change 1
1
package gitquery
2
2
3
3
import (
4
+ "io"
4
5
"strconv"
5
6
6
7
"gopkg.in/src-d/go-mysql-server.v0/sql"
@@ -57,31 +58,32 @@ func (treeEntriesTable) Children() []sql.Node {
57
58
58
59
type treeEntryIter struct {
59
60
i * object.TreeIter
61
+ fi * object.FileIter
60
62
t * object.Tree
61
- ei int
62
63
}
63
64
64
65
func (i * treeEntryIter ) Next () (sql.Row , error ) {
65
66
for {
66
- if i .t == nil {
67
- tree , err := i .i .Next ()
67
+ if i .fi == nil {
68
+ var err error
69
+ i .t , err = i .i .Next ()
68
70
if err != nil {
69
71
return nil , err
70
72
}
71
73
72
- i .t = tree
73
- i .ei = 0
74
+ i .fi = i .t .Files ()
74
75
}
75
76
76
- if i .ei >= len (i .t .Entries ) {
77
+ f , err := i .fi .Next ()
78
+ if err == io .EOF {
79
+ i .fi = nil
77
80
i .t = nil
78
81
continue
82
+ } else if err != nil {
83
+ return nil , err
79
84
}
80
85
81
- e := i .t .Entries [i .ei ]
82
- i .ei ++
83
-
84
- return treeEntryToRow (i .t , e ), nil
86
+ return fileToRow (i .t , f ), nil
85
87
}
86
88
}
87
89
@@ -90,11 +92,11 @@ func (i *treeEntryIter) Close() error {
90
92
return nil
91
93
}
92
94
93
- func treeEntryToRow (t * object.Tree , e object.TreeEntry ) sql.Row {
95
+ func fileToRow (t * object.Tree , f * object.File ) sql.Row {
94
96
return sql .NewRow (
95
97
t .ID ().String (),
96
- e .Hash .String (),
97
- strconv .FormatInt (int64 (e .Mode ), 8 ),
98
- e .Name ,
98
+ f .Hash .String (),
99
+ strconv .FormatInt (int64 (f .Mode ), 8 ),
100
+ f .Name ,
99
101
)
100
102
}
Original file line number Diff line number Diff line change 5
5
6
6
"gopkg.in/src-d/go-mysql-server.v0/sql"
7
7
8
- "gopkg.in/src-d/go-git-fixtures.v3"
9
8
"github.com/stretchr/testify/assert"
9
+ "gopkg.in/src-d/go-git-fixtures.v3"
10
10
)
11
11
12
12
func TestTreeEntriesTable_Name (t * testing.T ) {
@@ -33,7 +33,7 @@ func TestTreeEntriesTable_RowIter(t *testing.T) {
33
33
34
34
rows , err := sql .NodeToRows (table )
35
35
assert .Nil (err )
36
- assert .Len (rows , 45 )
36
+ assert .Len (rows , 49 )
37
37
38
38
schema := table .Schema ()
39
39
for idx , row := range rows {
You can’t perform that action at this time.
0 commit comments