From e8b6600c0a64f26bbfdcc04a7545a9dd89492183 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Fri, 11 Dec 2020 20:02:08 +0100 Subject: [PATCH] gitlab: simplify CIJobs a bit Rather than special-casing the first page, start out with an empty list and append each page. This is slightly less effective, but will make it easier to modify the list before returning it. --- internal/gitlab/gitlab.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/internal/gitlab/gitlab.go b/internal/gitlab/gitlab.go index 1312ba26..122fb927 100644 --- a/internal/gitlab/gitlab.go +++ b/internal/gitlab/gitlab.go @@ -839,14 +839,7 @@ func CIJobs(pid interface{}, sha string) ([]*gitlab.Job, error) { PerPage: 500, }, } - list, resp, err := lab.Jobs.ListPipelineJobs(pid, target, opts) - if err != nil { - return nil, err - } - if resp.CurrentPage == resp.TotalPages { - return list, nil - } - opts.Page = resp.NextPage + list := make([]*gitlab.Job, 0) for { jobs, resp, err := lab.Jobs.ListPipelineJobs(pid, target, opts) if err != nil {