@@ -144,28 +144,25 @@ type remotesRowIter struct {
144144}
145145
146146func (i * remotesRowIter ) Next () (sql.Row , error ) {
147- if i .remotePos >= len (i .remotes ) {
148- return nil , io .EOF
149- }
150-
151- remote := i .remotes [i .remotePos ]
152- config := remote .Config ()
153-
154- if i .urlPos >= len (config .URLs ) || i .urlPos >= len (config .Fetch ) {
155- i .remotePos ++
147+ for {
156148 if i .remotePos >= len (i .remotes ) {
157149 return nil , io .EOF
158150 }
159151
160- remote = i .remotes [i .remotePos ]
161- config = remote .Config ()
162- i .urlPos = 0
163- }
152+ remote := i .remotes [i .remotePos ]
153+ config := remote .Config ()
154+
155+ if i .urlPos >= len (config .URLs ) && i .urlPos >= len (config .Fetch ) {
156+ i .remotePos ++
157+ i .urlPos = 0
158+ continue
159+ }
164160
165- row := remoteToRow (i .repo .ID , config , i .urlPos )
166- i .urlPos ++
161+ row := remoteToRow (i .repo .ID , config , i .urlPos )
162+ i .urlPos ++
167163
168- return row , nil
164+ return row , nil
165+ }
169166}
170167
171168func (i * remotesRowIter ) Close () error {
@@ -177,13 +174,23 @@ func (i *remotesRowIter) Close() error {
177174}
178175
179176func remoteToRow (repoID string , config * config.RemoteConfig , pos int ) sql.Row {
177+ var url interface {}
178+ if pos < len (config .URLs ) {
179+ url = config .URLs [pos ]
180+ }
181+
182+ var fetch interface {}
183+ if pos < len (config .Fetch ) {
184+ fetch = config .Fetch [pos ].String ()
185+ }
186+
180187 return sql .NewRow (
181188 repoID ,
182189 config .Name ,
183- config . URLs [ pos ] ,
184- config . URLs [ pos ] ,
185- config . Fetch [ pos ]. String () ,
186- config . Fetch [ pos ]. String () ,
190+ url ,
191+ url ,
192+ fetch ,
193+ fetch ,
187194 )
188195}
189196
@@ -256,7 +263,8 @@ func (i *remotesKeyValueIter) Next() ([]interface{}, []byte, error) {
256263 }
257264
258265 cfg := i .remotes [i .pos ].Config ()
259- if i .urlPos >= len (cfg .URLs ) {
266+ if i .urlPos >= len (cfg .URLs ) && i .urlPos >= len (cfg .Fetch ) {
267+ i .urlPos = 0
260268 i .pos ++
261269 continue
262270 }
0 commit comments