From 6a62fe499e5842297e0b5db43e71e235eab057d7 Mon Sep 17 00:00:00 2001 From: Gorbunov Kirill Andreevich Date: Wed, 3 Apr 2024 01:02:54 +0300 Subject: [PATCH] #8 rebase. --- internal/source/gitea/gitea.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/source/gitea/gitea.go b/internal/source/gitea/gitea.go index dc27143..02b38a5 100644 --- a/internal/source/gitea/gitea.go +++ b/internal/source/gitea/gitea.go @@ -373,8 +373,9 @@ func (g *Gitea) RequestUpdate(ctx context.Context, branch string, path string, m func (g *Gitea) RequestList(ctx context.Context, branch string) (map[string]string, error) { logger.Debugf(ctx, fmt.Sprintf("RequestList for %s", branch)) + var err error - gPulls, err := GetPulls(ctx, g.URL, g.Owner, g.Repository, g.Token) + g.pulls, err = GetPulls(ctx, g.URL, g.Owner, g.Repository, g.Token) if err != nil { return nil, err } @@ -382,14 +383,13 @@ func (g *Gitea) RequestList(ctx context.Context, branch string) (map[string]stri var path string rMap := make(map[string]string) - for _, pull := range gPulls { + for _, pull := range g.pulls { if !strings.HasPrefix(pull.Title, "Bump ") { //добавляем только реквесты бота по обновлению модулей continue } path = strings.Split(pull.Title, " ")[1] //todo Работет только для дефолтного шаблона rMap[path] = pull.Title } - return rMap, nil } @@ -413,10 +413,11 @@ func DeleteBranch(ctx context.Context, url, owner, repo, branch, token string) ( } func GetPulls(ctx context.Context, url, owner, repo, token string) ([]*giteaPull, error) { - var pullsAll, pulls []*giteaPull + var pullsAll []*giteaPull page := 1 for { + pulls := make([]*giteaPull, 0, 10) req, err := http.NewRequestWithContext( ctx, http.MethodGet,