Skip to content

Commit fccac79

Browse files
authored
Merge branch 'master' into docs/perf-early-filters
2 parents a95efeb + 9e9a3f8 commit fccac79

File tree

4 files changed

+35
-22
lines changed

4 files changed

+35
-22
lines changed

integration_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,21 @@ func TestSquashCorrectness(t *testing.T) {
554554
ORDER BY num_files DESC
555555
LIMIT 10`,
556556

557+
`SELECT
558+
SUBSTRING(repository_id_part, 1, ARRAY_LENGTH(SPLIT(repository_id_part, ''))-4) AS repository_id,
559+
commit_author_when,
560+
commit_type
561+
FROM (
562+
SELECT
563+
SUBSTRING(remote_fetch_url, 18) AS repository_id_part,
564+
commit_author_when,
565+
CASE ARRAY_LENGTH(commit_parents) WHEN 0 THEN 'Commit' WHEN 1 THEN 'Commit' ELSE 'Merge' END AS commit_type
566+
FROM remotes
567+
NATURAL JOIN refs
568+
NATURAL JOIN commits
569+
) AS q
570+
LIMIT 1000`,
571+
557572
// Squash with non-squashable joins
558573
`SELECT * FROM refs NATURAL JOIN blobs`,
559574
`SELECT * FROM remotes NATURAL JOIN commits`,

ref_commits.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,10 @@ func (i *refCommitsRowIter) next() (sql.Row, error) {
292292
if i.commits == nil {
293293
var ref *plumbing.Reference
294294
if i.head == nil {
295-
var err_ error
296-
ref, err_ = i.refs.Next()
297-
if err_ != nil {
298-
if err_ == io.EOF {
295+
var err error
296+
ref, err = i.refs.Next()
297+
if err != nil {
298+
if err == io.EOF {
299299
i.repo.Close()
300300
return nil, io.EOF
301301
}
@@ -305,7 +305,7 @@ func (i *refCommitsRowIter) next() (sql.Row, error) {
305305
}
306306

307307
i.repo.Close()
308-
return nil, err_
308+
return nil, err
309309
}
310310
} else {
311311
ref = plumbing.NewHashReference(plumbing.ReferenceName("HEAD"), i.head.Hash())

remotes.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,7 @@ func remoteToRow(repoID string, config *config.RemoteConfig, pos int) sql.Row {
179179
url = config.URLs[pos]
180180
}
181181

182-
var fetch interface{}
183-
if pos < len(config.Fetch) {
184-
fetch = config.Fetch[pos].String()
185-
}
186-
182+
fetch := remoteFetchURL(config, pos)
187183
return sql.NewRow(
188184
repoID,
189185
config.Name,
@@ -326,3 +322,15 @@ func (i *remotesIndexIter) Close() error {
326322

327323
return i.index.Close()
328324
}
325+
326+
func remoteFetchURL(config *config.RemoteConfig, pos int) string {
327+
if len(config.Fetch) > 0 {
328+
var fpos = pos
329+
if fpos >= len(config.Fetch) {
330+
fpos = len(config.Fetch) - 1
331+
}
332+
return config.Fetch[fpos].String()
333+
}
334+
335+
return config.URLs[pos]
336+
}

squash_iterator.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -201,16 +201,11 @@ func (i *squashRemoteIter) Advance() error {
201201
config = remote.Config()
202202
}
203203

204-
fetch := i.urlPos
205-
if fetch >= len(config.Fetch) {
206-
fetch = len(config.Fetch) - 1
207-
}
208-
209204
i.remote = &Remote{
210205
RepoID: i.repo.ID,
211206
Name: config.Name,
212207
URL: config.URLs[i.urlPos],
213-
Fetch: config.Fetch[fetch].String(),
208+
Fetch: remoteFetchURL(config, i.urlPos),
214209
}
215210

216211
i.row = sql.NewRow(
@@ -330,16 +325,11 @@ func (i *squashRepoRemotesIter) Advance() error {
330325
config = remote.Config()
331326
}
332327

333-
fetch := i.urlPos
334-
if fetch >= len(config.Fetch) {
335-
fetch = len(config.Fetch) - 1
336-
}
337-
338328
i.remote = &Remote{
339329
RepoID: i.repos.Repository().ID,
340330
Name: config.Name,
341331
URL: config.URLs[i.urlPos],
342-
Fetch: config.Fetch[fetch].String(),
332+
Fetch: remoteFetchURL(config, i.urlPos),
343333
}
344334

345335
i.urlPos++

0 commit comments

Comments
 (0)