Skip to content

Commit a728d1e

Browse files
authored
always use headCommitID for review comment diff (#14011)
1 parent 7f85728 commit a728d1e

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

services/pull/review.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,16 +167,16 @@ func createCodeComment(doer *models.User, repo *models.Repository, issue *models
167167

168168
// Only fetch diff if comment is review comment
169169
if len(patch) == 0 && reviewID != 0 {
170+
headCommitID, err := gitRepo.GetRefCommitID(pr.GetGitRefName())
171+
if err != nil {
172+
return nil, fmt.Errorf("GetRefCommitID[%s]: %v", pr.GetGitRefName(), err)
173+
}
170174
if len(commitID) == 0 {
171-
commitID, err = gitRepo.GetRefCommitID(pr.GetGitRefName())
172-
if err != nil {
173-
return nil, fmt.Errorf("GetRefCommitID[%s]: %v", pr.GetGitRefName(), err)
174-
}
175+
commitID = headCommitID
175176
}
176-
177177
patchBuf := new(bytes.Buffer)
178-
if err := git.GetRepoRawDiffForFile(gitRepo, pr.MergeBase, commitID, git.RawDiffNormal, treePath, patchBuf); err != nil {
179-
return nil, fmt.Errorf("GetRawDiffForLine[%s, %s, %s, %s]: %v", gitRepo.Path, pr.MergeBase, commitID, treePath, err)
178+
if err := git.GetRepoRawDiffForFile(gitRepo, pr.MergeBase, headCommitID, git.RawDiffNormal, treePath, patchBuf); err != nil {
179+
return nil, fmt.Errorf("GetRawDiffForLine[%s, %s, %s, %s]: %v", gitRepo.Path, pr.MergeBase, headCommitID, treePath, err)
180180
}
181181
patch = git.CutDiffAroundLine(patchBuf, int64((&models.Comment{Line: line}).UnsignedLine()), line < 0, setting.UI.CodeCommentLines)
182182
}

0 commit comments

Comments
 (0)