#8 add gitlab #13

Closed
kgorbunov wants to merge 93 commits from kgorbunov/pkgdash:master into master
Showing only changes of commit d12b2d999f - Show all commits

View File

@ -404,13 +404,14 @@ 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 pulls []*giteaPull var pullsAll, pulls []*giteaPull
var err error page := 1
for page != 0 {
req, err := http.NewRequestWithContext( req, err := http.NewRequestWithContext(
ctx, ctx,
http.MethodGet, http.MethodGet,
fmt.Sprintf("https://%s/api/v1//repos/%s/%s/pulls?state=open&page=99&token=%s", url, owner, repo, token), fmt.Sprintf("https://%s/api/v1//repos/%s/%s/pulls?state=open&page=%s&token=%s", url, owner, repo, page, token),
nil) nil)
if err != nil { if err != nil {
return nil, err return nil, err
@ -432,11 +433,19 @@ func GetPulls(ctx context.Context, url, owner, repo, token string) ([]*giteaPull
logger.Error(ctx, fmt.Sprintf("failed to decode response %s err: %v", buf, err)) logger.Error(ctx, fmt.Sprintf("failed to decode response %s err: %v", buf, err))
return nil, err return nil, err
} }
return pulls, nil if len(pulls) == 0 {
page = 0
break
}
pullsAll = append(pullsAll, pulls...)
page++
case http.StatusNotFound: case http.StatusNotFound:
logger.Info(ctx, "PL is not exist for %s", repo) logger.Info(ctx, "PL is not exist for %s", repo)
return nil, ErrPRNotExist return nil, ErrPRNotExist
default: default:
return nil, fmt.Errorf("unknown error: %s", buf) return nil, fmt.Errorf("unknown error: %s", buf)
} }
}
return pullsAll, nil
} }