mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 10:18:38 +00:00
Decouple diff stats query from actual diffing (#33810)
The diff stats are no longer part of the diff generation. Use `GetDiffShortStat` instead to get the total number of changed files, added lines, and deleted lines. As such, `gitdiff.GetDiff` can be simplified: It should not do more than expected. And do not run "git diff --shortstat" for pull list. Fix #31492
This commit is contained in:
@@ -1591,6 +1591,7 @@ func GetPullRequestFiles(ctx *context.APIContext) {
|
||||
maxLines := setting.Git.MaxGitDiffLines
|
||||
|
||||
// FIXME: If there are too many files in the repo, may cause some unpredictable issues.
|
||||
// FIXME: it doesn't need to call "GetDiff" to do various parsing and highlighting
|
||||
diff, err := gitdiff.GetDiff(ctx, baseGitRepo,
|
||||
&gitdiff.DiffOptions{
|
||||
BeforeCommitID: startCommitID,
|
||||
@@ -1606,9 +1607,14 @@ func GetPullRequestFiles(ctx *context.APIContext) {
|
||||
return
|
||||
}
|
||||
|
||||
diffShortStat, err := gitdiff.GetDiffShortStat(baseGitRepo, startCommitID, endCommitID)
|
||||
if err != nil {
|
||||
ctx.APIErrorInternal(err)
|
||||
return
|
||||
}
|
||||
listOptions := utils.GetListOptions(ctx)
|
||||
|
||||
totalNumberOfFiles := diff.NumFiles
|
||||
totalNumberOfFiles := diffShortStat.NumFiles
|
||||
totalNumberOfPages := int(math.Ceil(float64(totalNumberOfFiles) / float64(listOptions.PageSize)))
|
||||
|
||||
start, limit := listOptions.GetSkipTake()
|
||||
|
Reference in New Issue
Block a user