Skip to content

Commit 0cf45c3

Browse files
committed
Don't send trigger for a pending review's comment create/update/delete
1 parent 1d4ad5a commit 0cf45c3

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

models/issues/comment.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,8 @@ func (c *Comment) LoadReactions(ctx context.Context, repo *repo_model.Repository
715715
return nil
716716
}
717717

718-
func (c *Comment) loadReview(ctx context.Context) (err error) {
718+
// LoadReview loads the associated review
719+
func (c *Comment) LoadReview(ctx context.Context) (err error) {
719720
if c.ReviewID == 0 {
720721
return nil
721722
}
@@ -732,11 +733,6 @@ func (c *Comment) loadReview(ctx context.Context) (err error) {
732733
return nil
733734
}
734735

735-
// LoadReview loads the associated review
736-
func (c *Comment) LoadReview(ctx context.Context) error {
737-
return c.loadReview(ctx)
738-
}
739-
740736
// DiffSide returns "previous" if Comment.Line is a LOC of the previous changes and "proposed" if it is a LOC of the proposed changes.
741737
func (c *Comment) DiffSide() string {
742738
if c.Line < 0 {
@@ -856,7 +852,7 @@ func updateCommentInfos(ctx context.Context, opts *CreateCommentOptions, comment
856852
}
857853
if comment.ReviewID != 0 {
858854
if comment.Review == nil {
859-
if err := comment.loadReview(ctx); err != nil {
855+
if err := comment.LoadReview(ctx); err != nil {
860856
return err
861857
}
862858
}

services/notify/notify.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ func DeleteWikiPage(ctx context.Context, doer *user_model.User, repo *repo_model
5050
func CreateIssueComment(ctx context.Context, doer *user_model.User, repo *repo_model.Repository,
5151
issue *issues_model.Issue, comment *issues_model.Comment, mentions []*user_model.User,
5252
) {
53+
if err := comment.LoadReview(ctx); err != nil {
54+
log.Error("LoadReview: %v", err)
55+
return
56+
} else if comment.Review != nil && comment.Review.Type == issues_model.ReviewTypePending {
57+
// Pending review comments updating should not triggered
58+
return
59+
}
60+
5361
for _, notifier := range notifiers {
5462
notifier.CreateIssueComment(ctx, doer, repo, issue, comment, mentions)
5563
}
@@ -156,13 +164,29 @@ func PullReviewDismiss(ctx context.Context, doer *user_model.User, review *issue
156164

157165
// UpdateComment notifies update comment to notifiers
158166
func UpdateComment(ctx context.Context, doer *user_model.User, c *issues_model.Comment, oldContent string) {
167+
if err := c.LoadReview(ctx); err != nil {
168+
log.Error("LoadReview: %v", err)
169+
return
170+
} else if c.Review != nil && c.Review.Type == issues_model.ReviewTypePending {
171+
// Pending review comments updating should not triggered
172+
return
173+
}
174+
159175
for _, notifier := range notifiers {
160176
notifier.UpdateComment(ctx, doer, c, oldContent)
161177
}
162178
}
163179

164180
// DeleteComment notifies delete comment to notifiers
165181
func DeleteComment(ctx context.Context, doer *user_model.User, c *issues_model.Comment) {
182+
if err := c.LoadReview(ctx); err != nil {
183+
log.Error("LoadReview: %v", err)
184+
return
185+
} else if c.Review != nil && c.Review.Type == issues_model.ReviewTypePending {
186+
// Pending review comments updating should not triggered
187+
return
188+
}
189+
166190
for _, notifier := range notifiers {
167191
notifier.DeleteComment(ctx, doer, c)
168192
}

0 commit comments

Comments
 (0)