From 687acd85c7a25cbaace49e0f57c84dd981124410 Mon Sep 17 00:00:00 2001 From: Gorbunov Kirill Andreevich Date: Sun, 31 Mar 2024 17:18:46 +0300 Subject: [PATCH] #8 execute all page pr --- internal/source/gitea/gitea.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/source/gitea/gitea.go b/internal/source/gitea/gitea.go index 1de67c5..894ad80 100644 --- a/internal/source/gitea/gitea.go +++ b/internal/source/gitea/gitea.go @@ -407,7 +407,7 @@ func GetPulls(ctx context.Context, url, owner, repo, token string) ([]*giteaPull var pullsAll, pulls []*giteaPull page := 1 - for page != 0 { + for { req, err := http.NewRequestWithContext( ctx, http.MethodGet, @@ -427,16 +427,16 @@ func GetPulls(ctx context.Context, url, owner, repo, token string) ([]*giteaPull buf, _ := io.ReadAll(rsp.Body) + if buf == nil { + break + } + switch rsp.StatusCode { case http.StatusOK: if err = json.Unmarshal(buf, &pulls); err != nil { logger.Error(ctx, fmt.Sprintf("failed to decode response %s err: %v", buf, err)) return nil, err } - if len(pulls) == 0 { - page = 0 - break - } pullsAll = append(pullsAll, pulls...) page++ case http.StatusNotFound: