@@ -200,22 +200,13 @@ func GetPullDiffStats(ctx *context.Context) {
200
200
return
201
201
}
202
202
203
- diffOptions := & gitdiff.DiffOptions {
204
- BeforeCommitID : mergeBaseCommitID ,
205
- AfterCommitID : headCommitID ,
206
- MaxLines : setting .Git .MaxGitDiffLines ,
207
- MaxLineCharacters : setting .Git .MaxGitDiffLineCharacters ,
208
- MaxFiles : setting .Git .MaxGitDiffFiles ,
209
- WhitespaceBehavior : gitdiff .GetWhitespaceFlag (ctx .Data ["WhitespaceBehavior" ].(string )),
210
- }
211
-
212
- diff , err := gitdiff .GetPullDiffStats (ctx .Repo .GitRepo , diffOptions )
203
+ diffShortStat , err := gitdiff .GetDiffShortStat (ctx .Repo .GitRepo , mergeBaseCommitID , headCommitID )
213
204
if err != nil {
214
- ctx .ServerError ("GetPullDiffStats " , err )
205
+ ctx .ServerError ("GetDiffShortStat " , err )
215
206
return
216
207
}
217
208
218
- ctx .Data ["Diff " ] = diff
209
+ ctx .Data ["DiffShortStat " ] = diffShortStat
219
210
}
220
211
221
212
func GetMergedBaseCommitID (ctx * context.Context , issue * issues_model.Issue ) string {
@@ -752,36 +743,43 @@ func viewPullFiles(ctx *context.Context, specifiedStartCommit, specifiedEndCommi
752
743
MaxLineCharacters : setting .Git .MaxGitDiffLineCharacters ,
753
744
MaxFiles : maxFiles ,
754
745
WhitespaceBehavior : gitdiff .GetWhitespaceFlag (ctx .Data ["WhitespaceBehavior" ].(string )),
755
- FileOnly : fileOnly ,
756
746
}
757
747
758
748
if ! willShowSpecifiedCommit {
759
749
diffOptions .BeforeCommitID = startCommitID
760
750
}
761
751
762
- var methodWithError string
763
- var diff * gitdiff.Diff
764
- shouldGetUserSpecificDiff := false
752
+ diff , err := gitdiff .GetDiff (ctx , gitRepo , diffOptions , files ... )
753
+ if err != nil {
754
+ ctx .ServerError ("GetDiff" , err )
755
+ return
756
+ }
765
757
766
758
// if we're not logged in or only a single commit (or commit range) is shown we
767
759
// have to load only the diff and not get the viewed information
768
760
// as the viewed information is designed to be loaded only on latest PR
769
761
// diff and if you're signed in.
762
+ shouldGetUserSpecificDiff := false
770
763
if ! ctx .IsSigned || willShowSpecifiedCommit || willShowSpecifiedCommitRange {
771
- diff , err = gitdiff .GetDiff (ctx , gitRepo , diffOptions , files ... )
772
- methodWithError = "GetDiff"
764
+ // do nothing
773
765
} else {
774
- diff , err = gitdiff .SyncAndGetUserSpecificDiff (ctx , ctx .Doer .ID , pull , gitRepo , diffOptions , files ... )
775
- methodWithError = "SyncAndGetUserSpecificDiff"
776
766
shouldGetUserSpecificDiff = true
767
+ err = gitdiff .SyncUserSpecificDiff (ctx , ctx .Doer .ID , pull , gitRepo , diff , diffOptions , files ... )
768
+ if err != nil {
769
+ ctx .ServerError ("SyncUserSpecificDiff" , err )
770
+ return
771
+ }
777
772
}
773
+
774
+ diffShortStat , err := gitdiff .GetDiffShortStat (ctx .Repo .GitRepo , startCommitID , endCommitID )
778
775
if err != nil {
779
- ctx .ServerError (methodWithError , err )
776
+ ctx .ServerError ("GetDiffShortStat" , err )
780
777
return
781
778
}
779
+ ctx .Data ["DiffShortStat" ] = diffShortStat
782
780
783
781
ctx .PageData ["prReview" ] = map [string ]any {
784
- "numberOfFiles" : diff .NumFiles ,
782
+ "numberOfFiles" : diffShortStat .NumFiles ,
785
783
"numberOfViewedFiles" : diff .NumViewedFiles ,
786
784
}
787
785
@@ -840,7 +838,7 @@ func viewPullFiles(ctx *context.Context, specifiedStartCommit, specifiedEndCommi
840
838
}
841
839
842
840
ctx .Data ["Diff" ] = diff
843
- ctx .Data ["DiffNotAvailable" ] = diff .NumFiles == 0
841
+ ctx .Data ["DiffNotAvailable" ] = diffShortStat .NumFiles == 0
844
842
845
843
baseCommit , err := ctx .Repo .GitRepo .GetCommit (startCommitID )
846
844
if err != nil {
0 commit comments