#8 skip path if branch exists (#12)

Co-authored-by: Gorbunov Kirill Andreevich <kgorbunov@mtsbank.ru>
Reviewed-on: #12
Co-authored-by: Кирилл Горбунов <kirya_gorbunov_2015@mail.ru>
Co-committed-by: Кирилл Горбунов <kirya_gorbunov_2015@mail.ru>
This commit is contained in:
Кирилл Горбунов
2024-04-03 08:28:16 +03:00
parent eb2a21a1b1
commit bf99e383e3
5 changed files with 10 additions and 15 deletions

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) {
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,