#19 #20
@ -407,7 +407,7 @@ func GetPulls(ctx context.Context, url, owner, repo, token string) ([]*giteaPull
|
|||||||
var pullsAll, pulls []*giteaPull
|
var pullsAll, pulls []*giteaPull
|
||||||
page := 1
|
page := 1
|
||||||
|
|
||||||
for page != 0 {
|
for {
|
||||||
req, err := http.NewRequestWithContext(
|
req, err := http.NewRequestWithContext(
|
||||||
ctx,
|
ctx,
|
||||||
http.MethodGet,
|
http.MethodGet,
|
||||||
@ -427,16 +427,16 @@ func GetPulls(ctx context.Context, url, owner, repo, token string) ([]*giteaPull
|
|||||||
|
|
||||||
buf, _ := io.ReadAll(rsp.Body)
|
buf, _ := io.ReadAll(rsp.Body)
|
||||||
|
|
||||||
|
if buf == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
switch rsp.StatusCode {
|
switch rsp.StatusCode {
|
||||||
case http.StatusOK:
|
case http.StatusOK:
|
||||||
if err = json.Unmarshal(buf, &pulls); err != nil {
|
if err = json.Unmarshal(buf, &pulls); err != nil {
|
||||||
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
|
||||||
}
|
}
|
||||||
if len(pulls) == 0 {
|
|
||||||
page = 0
|
|
||||||
break
|
|
||||||
}
|
|
||||||
pullsAll = append(pullsAll, pulls...)
|
pullsAll = append(pullsAll, pulls...)
|
||||||
page++
|
page++
|
||||||
case http.StatusNotFound:
|
case http.StatusNotFound:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user