@@ -257,12 +257,24 @@ func PrepareMergedViewPullInfo(ctx *context.Context, issue *models.Issue) {
257
257
setMergeTarget (ctx , pull )
258
258
ctx .Data ["HasMerged" ] = true
259
259
260
- ctx .Data ["NumCommits" ], err = ctx .Repo .GitRepo .CommitsCountBetween (pull .MergeBase , pull .MergedCommitID )
260
+ mergedCommit , err := ctx .Repo .GitRepo .GetCommit (pull .MergedCommitID )
261
+ if err != nil {
262
+ ctx .Handle (500 , "GetCommit" , err )
263
+ return
264
+ }
265
+ // the ID of the last commit in the PR (not including the merge commit)
266
+ endCommitID , err := mergedCommit .ParentID (mergedCommit .ParentCount () - 1 )
267
+ if err != nil {
268
+ ctx .Handle (500 , "ParentID" , err )
269
+ return
270
+ }
271
+
272
+ ctx .Data ["NumCommits" ], err = ctx .Repo .GitRepo .CommitsCountBetween (pull .MergeBase , endCommitID .String ())
261
273
if err != nil {
262
274
ctx .Handle (500 , "Repo.GitRepo.CommitsCountBetween" , err )
263
275
return
264
276
}
265
- ctx .Data ["NumFiles" ], err = ctx .Repo .GitRepo .FilesCountBetween (pull .MergeBase , pull . MergedCommitID )
277
+ ctx .Data ["NumFiles" ], err = ctx .Repo .GitRepo .FilesCountBetween (pull .MergeBase , endCommitID . String () )
266
278
if err != nil {
267
279
ctx .Handle (500 , "Repo.GitRepo.FilesCountBetween" , err )
268
280
return
@@ -338,19 +350,19 @@ func ViewPullCommits(ctx *context.Context) {
338
350
ctx .Data ["Username" ] = ctx .Repo .Owner .Name
339
351
ctx .Data ["Reponame" ] = ctx .Repo .Repository .Name
340
352
341
- startCommit , err := ctx .Repo .GitRepo .GetCommit (pull .MergeBase )
353
+ mergedCommit , err := ctx .Repo .GitRepo .GetCommit (pull .MergedCommitID )
342
354
if err != nil {
343
355
ctx .Handle (500 , "Repo.GitRepo.GetCommit" , err )
344
356
return
345
357
}
346
- endCommit , err := ctx . Repo . GitRepo . GetCommit ( pull . MergedCommitID )
358
+ endCommitID , err := mergedCommit . ParentID ( mergedCommit . ParentCount () - 1 )
347
359
if err != nil {
348
- ctx .Handle (500 , "Repo.GitRepo.GetCommit " , err )
360
+ ctx .Handle (500 , "ParentID " , err )
349
361
return
350
362
}
351
- commits , err = ctx .Repo .GitRepo .CommitsBetween ( endCommit , startCommit )
363
+ commits , err = ctx .Repo .GitRepo .CommitsBetweenIDs ( endCommitID . String (), pull . MergeBase )
352
364
if err != nil {
353
- ctx .Handle (500 , "Repo.GitRepo.CommitsBetween " , err )
365
+ ctx .Handle (500 , "Repo.GitRepo.CommitsBetweenIDs " , err )
354
366
return
355
367
}
356
368
} else {
@@ -402,7 +414,17 @@ func ViewPullFiles(ctx *context.Context) {
402
414
403
415
diffRepoPath = ctx .Repo .GitRepo .Path
404
416
startCommitID = pull .MergeBase
405
- endCommitID = pull .MergedCommitID
417
+ mergedCommit , err := ctx .Repo .GitRepo .GetCommit (pull .MergedCommitID )
418
+ if err != nil {
419
+ ctx .Handle (500 , "GetCommit" , err )
420
+ return
421
+ }
422
+ endCommitSha , err := mergedCommit .ParentID (mergedCommit .ParentCount () - 1 )
423
+ if err != nil {
424
+ ctx .Handle (500 , "ParentID" , err )
425
+ return
426
+ }
427
+ endCommitID = endCommitSha .String ()
406
428
gitRepo = ctx .Repo .GitRepo
407
429
408
430
headTarget = path .Join (ctx .Repo .Owner .Name , ctx .Repo .Repository .Name )
0 commit comments