Fix pull requests API convert panic when head repository is deleted. (#34685) (#34687)
Some checks are pending
release-nightly / nightly-binary (push) Waiting to run
release-nightly / nightly-docker-rootful (push) Waiting to run
release-nightly / nightly-docker-rootless (push) Waiting to run

Backport #34685 by @lunny

Fix #34682

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
Giteabot
2025-06-11 11:45:04 +08:00
committed by GitHub
parent 64b9b21790
commit 2eecd58bbe
2 changed files with 18 additions and 11 deletions

View File

@ -46,4 +46,11 @@ func TestPullRequest_APIFormat(t *testing.T) {
assert.NotNil(t, apiPullRequest)
assert.Nil(t, apiPullRequest.Head.Repository)
assert.EqualValues(t, -1, apiPullRequest.Head.RepoID)
apiPullRequests, err := ToAPIPullRequests(git.DefaultContext, pr.BaseRepo, []*issues_model.PullRequest{pr}, nil)
assert.NoError(t, err)
assert.Len(t, apiPullRequests, 1)
assert.NotNil(t, apiPullRequests[0])
assert.Nil(t, apiPullRequests[0].Head.Repository)
assert.EqualValues(t, -1, apiPullRequests[0].Head.RepoID)
}