Skip to content

Commit

Permalink
gitlab: simplify CIJobs a bit
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fmuellner committed Dec 11, 2020
1 parent 8b0c915 commit e8b6600
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions internal/gitlab/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit e8b6600

Please sign in to comment.