@@ -167,16 +167,16 @@ func createCodeComment(doer *models.User, repo *models.Repository, issue *models
167
167
168
168
// Only fetch diff if comment is review comment
169
169
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
+ }
170
174
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
175
176
}
176
-
177
177
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 )
180
180
}
181
181
patch = git .CutDiffAroundLine (patchBuf , int64 ((& models.Comment {Line : line }).UnsignedLine ()), line < 0 , setting .UI .CodeCommentLines )
182
182
}
0 commit comments