@@ -19,9 +19,28 @@ import (
19
19
20
20
// CreateCodeComment creates a comment on the code line
21
21
func CreateCodeComment (doer * models.User , issue * models.Issue , line int64 , content string , treePath string , isReview bool , replyReviewID int64 ) (* models.Comment , error ) {
22
- // It's not a review, maybe a reply to a review comment or a single comment.
22
+
23
+ var (
24
+ existsReview bool
25
+ err error
26
+ )
27
+
28
+ // CreateCodeComment() is used for:
29
+ // - Single comments
30
+ // - Comments that are part of a review
31
+ // - Comments that reply to an existing review
32
+
23
33
if ! isReview {
24
- if err := issue .LoadRepo (); err != nil {
34
+ // It's not part of a review; maybe a reply to a review comment or a single comment.
35
+ // Check if there are reviews for that line already; if there are, this is a reply
36
+ if existsReview , err = models .ReviewExists (issue , treePath , line ); err != nil {
37
+ return nil , err
38
+ }
39
+ }
40
+
41
+ // Comments that are replies don't require a review header to show up in the issue view
42
+ if ! isReview && existsReview {
43
+ if err = issue .LoadRepo (); err != nil {
25
44
return nil , err
26
45
}
27
46
@@ -72,7 +91,14 @@ func CreateCodeComment(doer *models.User, issue *models.Issue, line int64, conte
72
91
return nil , err
73
92
}
74
93
75
- // NOTICE: it's a pending review, so the notifications will not be fired until user submit review.
94
+ if ! isReview && ! existsReview {
95
+ // Submit the review we've just created so the comment shows up in the issue view
96
+ if _ , _ , err = SubmitReview (doer , issue , models .ReviewTypeComment , "" ); err != nil {
97
+ return nil , err
98
+ }
99
+ }
100
+
101
+ // NOTICE: if it's a pending review the notifications will not be fired until user submit review.
76
102
77
103
return comment , nil
78
104
}
0 commit comments