mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-25 11:21:02 +00:00
Handle empty repositories in gitea when listing PRs (#3925)
This commit is contained in:
parent
cd5f6f71a2
commit
1274de2b2d
1 changed files with 7 additions and 2 deletions
|
@ -472,12 +472,17 @@ func (c *Gitea) PullRequests(ctx context.Context, u *model.User, r *model.Repo,
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
pullRequests, _, err := client.ListRepoPullRequests(r.Owner, r.Name, gitea.ListPullRequestsOptions{
|
pullRequests, resp, err := client.ListRepoPullRequests(r.Owner, r.Name, gitea.ListPullRequestsOptions{
|
||||||
ListOptions: gitea.ListOptions{Page: p.Page, PageSize: p.PerPage},
|
ListOptions: gitea.ListOptions{Page: p.Page, PageSize: p.PerPage},
|
||||||
State: gitea.StateOpen,
|
State: gitea.StateOpen,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
// Repositories without commits return empty list with status code 404
|
||||||
|
if pullRequests != nil && resp != nil && resp.StatusCode == http.StatusNotFound {
|
||||||
|
err = nil
|
||||||
|
} else {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result := make([]*model.PullRequest, len(pullRequests))
|
result := make([]*model.PullRequest, len(pullRequests))
|
||||||
|
|
Loading…
Reference in a new issue