Handle empty repositories in gitea when listing PRs (#3925)

This commit is contained in:
Harri Avellan 2024-07-18 14:30:45 +03:00 committed by GitHub
parent cd5f6f71a2
commit 1274de2b2d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -472,13 +472,18 @@ 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 {
// 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 return nil, err
} }
}
result := make([]*model.PullRequest, len(pullRequests)) result := make([]*model.PullRequest, len(pullRequests))
for i := range pullRequests { for i := range pullRequests {