From b607e0b053897ffdb81af1f37095d13a2b5080a6 Mon Sep 17 00:00:00 2001 From: Jordan Brockopp Date: Thu, 7 May 2020 09:29:27 -0500 Subject: [PATCH] fix: capturing build history for repo (#22) * fix: support repos without 500 builds * fix: append builds after API call --- cmd/vela-downstream/plugin.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cmd/vela-downstream/plugin.go b/cmd/vela-downstream/plugin.go index 0e33c34..c2a758b 100644 --- a/cmd/vela-downstream/plugin.go +++ b/cmd/vela-downstream/plugin.go @@ -64,15 +64,16 @@ func (p *Plugin) Exec() error { return fmt.Errorf("unable to list builds for %s: %w", repo.GetFullName(), err) } - // break the loop after 5 pages of results - // giving us a total of 500 builds collected - if resp.NextPage > 5 { - break - } - // add the results to the list of builds builds = append(builds, *b...) + // break the loop if there is no more results + // to page through or after 5 pages of results + // giving us up to a total of 500 builds + if resp.NextPage == 0 || resp.NextPage > 5 { + break + } + // update the options for listing builds // to point at the next page opts.Page = resp.NextPage