summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJimmy Praet <jimmy.praet@telenet.be>2020-12-16 11:50:30 +0100
committerGitHub <noreply@github.com>2020-12-16 18:50:30 +0800
commita728d1e046d8d831276eea4ab7f84f700a76f34d (patch)
tree911c489217c0f2527a09e9891e47d9373ce942ad
parent7f85728cf9c6ab1dcec5ed1be1dc66cef24634c3 (diff)
downloadgitea-a728d1e046d8d831276eea4ab7f84f700a76f34d.tar.gz
gitea-a728d1e046d8d831276eea4ab7f84f700a76f34d.zip
always use headCommitID for review comment diff (#14011)
-rw-r--r--services/pull/review.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/services/pull/review.go b/services/pull/review.go
index f0ee234a42..6781136061 100644
--- a/services/pull/review.go
+++ b/services/pull/review.go
@@ -167,16 +167,16 @@ func createCodeComment(doer *models.User, repo *models.Repository, issue *models
// Only fetch diff if comment is review comment
if len(patch) == 0 && reviewID != 0 {
+ headCommitID, err := gitRepo.GetRefCommitID(pr.GetGitRefName())
+ if err != nil {
+ return nil, fmt.Errorf("GetRefCommitID[%s]: %v", pr.GetGitRefName(), err)
+ }
if len(commitID) == 0 {
- commitID, err = gitRepo.GetRefCommitID(pr.GetGitRefName())
- if err != nil {
- return nil, fmt.Errorf("GetRefCommitID[%s]: %v", pr.GetGitRefName(), err)
- }
+ commitID = headCommitID
}
-
patchBuf := new(bytes.Buffer)
- if err := git.GetRepoRawDiffForFile(gitRepo, pr.MergeBase, commitID, git.RawDiffNormal, treePath, patchBuf); err != nil {
- return nil, fmt.Errorf("GetRawDiffForLine[%s, %s, %s, %s]: %v", gitRepo.Path, pr.MergeBase, commitID, treePath, err)
+ if err := git.GetRepoRawDiffForFile(gitRepo, pr.MergeBase, headCommitID, git.RawDiffNormal, treePath, patchBuf); err != nil {
+ return nil, fmt.Errorf("GetRawDiffForLine[%s, %s, %s, %s]: %v", gitRepo.Path, pr.MergeBase, headCommitID, treePath, err)
}
patch = git.CutDiffAroundLine(patchBuf, int64((&models.Comment{Line: line}).UnsignedLine()), line < 0, setting.UI.CodeCommentLines)
}