Skip to content

Commit 925fedc

Browse files
committed
assign startCommitID as the endcommit parent when viewfing specific commit in pull
1 parent 7fb93fe commit 925fedc

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

routers/web/repo/pull.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,22 @@ func viewPullFiles(ctx *context.Context, specifiedStartCommit, specifiedEndCommi
748748

749749
if !willShowSpecifiedCommit {
750750
diffOptions.BeforeCommitID = startCommitID
751+
} else {
752+
endCommit, err := gitRepo.GetCommit(endCommitID)
753+
if err != nil {
754+
ctx.ServerError("GetCommit", err)
755+
return
756+
}
757+
758+
if endCommit.ParentCount() > 0 {
759+
endCommitParent, err := endCommit.Parent(0)
760+
if err != nil {
761+
ctx.ServerError("Parent", err)
762+
return
763+
}
764+
765+
startCommitID = endCommitParent.ID.String()
766+
}
751767
}
752768

753769
diff, err := gitdiff.GetDiffForRender(ctx, ctx.Repo.RepoLink, gitRepo, diffOptions, files...)

0 commit comments

Comments
 (0)