mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-01 05:36:19 +01:00
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
1 changed files with 4 additions and 2 deletions
|
@ -1420,8 +1420,9 @@ func GetPullRequestFiles(ctx *context.APIContext) {
|
|||
startCommitID := prInfo.MergeBase
|
||||
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,
|
||||
&gitdiff.DiffOptions{
|
||||
BeforeCommitID: startCommitID,
|
||||
|
@ -1429,7 +1430,7 @@ func GetPullRequestFiles(ctx *context.APIContext) {
|
|||
SkipTo: ctx.FormString("skip-to"),
|
||||
MaxLines: maxLines,
|
||||
MaxLineCharacters: setting.Git.MaxGitDiffLineCharacters,
|
||||
MaxFiles: maxFiles,
|
||||
MaxFiles: -1, // GetDiff() will return all files
|
||||
WhitespaceBehavior: gitdiff.GetWhitespaceFlag(ctx.FormString("whitespace")),
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -1452,6 +1453,7 @@ func GetPullRequestFiles(ctx *context.APIContext) {
|
|||
if lenFiles < 0 {
|
||||
lenFiles = 0
|
||||
}
|
||||
|
||||
apiFiles := make([]*api.ChangedFile, 0, lenFiles)
|
||||
for i := start; i < end; i++ {
|
||||
apiFiles = append(apiFiles, convert.ToChangedFile(diff.Files[i], pr.HeadRepo, endCommitID))
|
||||
|
|
Loading…
Reference in a new issue