Skip to content

Commit abc626d

Browse files
committed
fix test
Signed-off-by: Andrew Thornton <[email protected]>
1 parent 154a996 commit abc626d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

services/pull/review.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,9 +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+
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+
}
176+
170177
patchBuf := new(bytes.Buffer)
171178
if err := git.GetRepoRawDiffForFile(gitRepo, pr.MergeBase, commitID, git.RawDiffNormal, treePath, patchBuf); err != nil {
172-
return nil, fmt.Errorf("GetRawDiffForLine[%s, %s, %s, %s]: %v", err, gitRepo.Path, pr.MergeBase, commitID, treePath)
179+
return nil, fmt.Errorf("GetRawDiffForLine[%s, %s, %s, %s]: %v", gitRepo.Path, pr.MergeBase, commitID, treePath, err)
173180
}
174181
patch = git.CutDiffAroundLine(patchBuf, int64((&models.Comment{Line: line}).UnsignedLine()), line < 0, setting.UI.CodeCommentLines)
175182
}

0 commit comments

Comments
 (0)