Skip to content

Commit 4eb304f

Browse files
committed
gitbase: handle skip git errors in commit_blobs table iterator
Signed-off-by: Manuel Carmona <[email protected]>
1 parent c2b8b27 commit 4eb304f

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

commit_blobs.go

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,15 @@ func (commitBlobsTable) WithProjectAndFilters(
7878
return nil, err
7979
}
8080

81+
s, ok := ctx.Session.(*Session)
82+
if !ok {
83+
return nil, ErrInvalidGitbaseSession.New(ctx.Session)
84+
}
85+
8186
return &commitBlobsIter{
82-
repos: repos,
83-
commits: commits,
87+
repos: repos,
88+
commits: commits,
89+
skipGitErrors: s.SkipGitErrors,
8490
}, nil
8591
},
8692
)
@@ -94,10 +100,11 @@ func (commitBlobsTable) WithProjectAndFilters(
94100
}
95101

96102
type commitBlobsIter struct {
97-
repoID string
98-
iter object.CommitIter
99-
currCommit *object.Commit
100-
filesIter *object.FileIter
103+
repoID string
104+
iter object.CommitIter
105+
currCommit *object.Commit
106+
filesIter *object.FileIter
107+
skipGitErrors bool
101108

102109
// selectors for faster filtering
103110
repos []string
@@ -131,6 +138,10 @@ func (i *commitBlobsIter) Next() (sql.Row, error) {
131138
if i.currCommit == nil {
132139
commit, err := i.iter.Next()
133140
if err != nil {
141+
if err != io.EOF && i.skipGitErrors {
142+
continue
143+
}
144+
134145
return nil, err
135146
}
136147

@@ -140,6 +151,10 @@ func (i *commitBlobsIter) Next() (sql.Row, error) {
140151

141152
filesIter, err := commit.Files()
142153
if err != nil {
154+
if i.skipGitErrors {
155+
continue
156+
}
157+
143158
return nil, err
144159
}
145160

@@ -156,6 +171,10 @@ func (i *commitBlobsIter) Next() (sql.Row, error) {
156171
continue
157172
}
158173

174+
if i.skipGitErrors {
175+
continue
176+
}
177+
159178
return nil, err
160179
}
161180

0 commit comments

Comments
 (0)