This commit is contained in:
Gorbunov Kirill Andreevich 2024-04-03 01:02:54 +03:00
parent 1c3c88a48e
commit 6a62fe499e

View File

@ -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) { func (g *Gitea) RequestList(ctx context.Context, branch string) (map[string]string, error) {
logger.Debugf(ctx, fmt.Sprintf("RequestList for %s", branch)) 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 { if err != nil {
return nil, err return nil, err
} }
@ -382,14 +383,13 @@ func (g *Gitea) RequestList(ctx context.Context, branch string) (map[string]stri
var path string var path string
rMap := make(map[string]string) rMap := make(map[string]string)
for _, pull := range gPulls { for _, pull := range g.pulls {
if !strings.HasPrefix(pull.Title, "Bump ") { //добавляем только реквесты бота по обновлению модулей if !strings.HasPrefix(pull.Title, "Bump ") { //добавляем только реквесты бота по обновлению модулей
continue continue
} }
path = strings.Split(pull.Title, " ")[1] //todo Работет только для дефолтного шаблона path = strings.Split(pull.Title, " ")[1] //todo Работет только для дефолтного шаблона
rMap[path] = pull.Title rMap[path] = pull.Title
} }
return rMap, nil 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) { func GetPulls(ctx context.Context, url, owner, repo, token string) ([]*giteaPull, error) {
var pullsAll, pulls []*giteaPull var pullsAll []*giteaPull
page := 1 page := 1
for { for {
pulls := make([]*giteaPull, 0, 10)
req, err := http.NewRequestWithContext( req, err := http.NewRequestWithContext(
ctx, ctx,
http.MethodGet, http.MethodGet,