mirror of https://github.com/go-gitea/gitea.git
Fix panic when call api (/repos/{owner}/{repo}/pulls/{index}/files) (#22921)
Close: #22910 --- I'm confused about that why does the api (`GET /repos/{owner}/{repo}/pulls/{index}/files`) require caller to pass the parameters `limit` and `page`. In my case, the caller only needs to pass a `skip-to` to paging. This is consistent with the api `GET /{owner}/{repo}/pulls/{index}/files` So, I deleted the code related to `listOptions` --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
parent
c3d9a70d0a
commit
36d1d5fb78
|
@ -1420,8 +1420,9 @@ func GetPullRequestFiles(ctx *context.APIContext) {
|
||||||
startCommitID := prInfo.MergeBase
|
startCommitID := prInfo.MergeBase
|
||||||
endCommitID := headCommitID
|
endCommitID := headCommitID
|
||||||
|
|
||||||
maxLines, maxFiles := setting.Git.MaxGitDiffLines, setting.Git.MaxGitDiffFiles
|
maxLines := setting.Git.MaxGitDiffLines
|
||||||
|
|
||||||
|
// FIXME: If there are too many files in the repo, may cause some unpredictable issues.
|
||||||
diff, err := gitdiff.GetDiff(baseGitRepo,
|
diff, err := gitdiff.GetDiff(baseGitRepo,
|
||||||
&gitdiff.DiffOptions{
|
&gitdiff.DiffOptions{
|
||||||
BeforeCommitID: startCommitID,
|
BeforeCommitID: startCommitID,
|
||||||
|
@ -1429,7 +1430,7 @@ func GetPullRequestFiles(ctx *context.APIContext) {
|
||||||
SkipTo: ctx.FormString("skip-to"),
|
SkipTo: ctx.FormString("skip-to"),
|
||||||
MaxLines: maxLines,
|
MaxLines: maxLines,
|
||||||
MaxLineCharacters: setting.Git.MaxGitDiffLineCharacters,
|
MaxLineCharacters: setting.Git.MaxGitDiffLineCharacters,
|
||||||
MaxFiles: maxFiles,
|
MaxFiles: -1, // GetDiff() will return all files
|
||||||
WhitespaceBehavior: gitdiff.GetWhitespaceFlag(ctx.FormString("whitespace")),
|
WhitespaceBehavior: gitdiff.GetWhitespaceFlag(ctx.FormString("whitespace")),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1452,6 +1453,7 @@ func GetPullRequestFiles(ctx *context.APIContext) {
|
||||||
if lenFiles < 0 {
|
if lenFiles < 0 {
|
||||||
lenFiles = 0
|
lenFiles = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
apiFiles := make([]*api.ChangedFile, 0, lenFiles)
|
apiFiles := make([]*api.ChangedFile, 0, lenFiles)
|
||||||
for i := start; i < end; i++ {
|
for i := start; i < end; i++ {
|
||||||
apiFiles = append(apiFiles, convert.ToChangedFile(diff.Files[i], pr.HeadRepo, endCommitID))
|
apiFiles = append(apiFiles, convert.ToChangedFile(diff.Files[i], pr.HeadRepo, endCommitID))
|
||||||
|
|
Loading…
Reference in New Issue