Fix bug when API get pull changed files for deleted head repository (#34333)

This commit is contained in:
Lunny Xiao authored and GitHub committed 2025-05-04 19:17:17 +00:00
1 parent 41f3d062a2
commit 51aafb4278
2 files changed
+101 -1

No files matched your search

+3 -1
View File
@@ -1632,7 +1632,9 @@ func GetPullRequestFiles(ctx *context.APIContext) {
apiFiles := make([]*api.ChangedFile, 0, limit)
for i := start; i < start+limit; i++ {
apiFiles = append(apiFiles, convert.ToChangedFile(diff.Files[i], pr.HeadRepo, endCommitID))
// refs/pull/1/head stores the HEAD commit ID, allowing all related commits to be found in the base repository.
// The head repository might have been deleted, so we should not rely on it here.
apiFiles = append(apiFiles, convert.ToChangedFile(diff.Files[i], pr.BaseRepo, endCommitID))
}
ctx.SetLinkHeader(totalNumberOfFiles, listOptions.PageSize)