Skip to content

Commit 023ae3c

Browse files
guillep2kzeripath
authored andcommitted
Hotfix for review actions and notifications (#8965)
1 parent 3227a11 commit 023ae3c

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

models/issue_comment.go

+16-5
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,10 @@ func sendCreateCommentAction(e *xorm.Session, opts *CreateCommentOptions, commen
538538
switch opts.Type {
539539
case CommentTypeCode:
540540
if comment.ReviewID != 0 {
541+
// Hotfix for 1.10.0 as the Review object has not yet been committed in the other session
542+
if opts.Review != nil {
543+
comment.Review = opts.Review
544+
}
541545
if comment.Review == nil {
542546
if err := comment.loadReview(e); err != nil {
543547
return err
@@ -596,6 +600,12 @@ func sendCreateCommentAction(e *xorm.Session, opts *CreateCommentOptions, commen
596600
if err = opts.Issue.updateClosedNum(e); err != nil {
597601
return err
598602
}
603+
case CommentTypeReview:
604+
// Hotfix for 1.10.0; make sure a dashboard entry is created
605+
if opts.Content == "" {
606+
return nil
607+
}
608+
act.OpType = ActionCommentIssue
599609
}
600610
// update the issue's updated_unix column
601611
if err = updateIssueCols(e, opts.Issue, "updated_unix"); err != nil {
@@ -751,11 +761,12 @@ func createIssueDependencyComment(e *xorm.Session, doer *User, issue *Issue, dep
751761

752762
// CreateCommentOptions defines options for creating comment
753763
type CreateCommentOptions struct {
754-
Type CommentType
755-
Doer *User
756-
Repo *Repository
757-
Issue *Issue
758-
Label *Label
764+
Type CommentType
765+
Doer *User
766+
Repo *Repository
767+
Issue *Issue
768+
Label *Label
769+
Review *Review
759770

760771
DependentIssueID int64
761772
OldMilestoneID int64

models/review.go

+1
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ func (r *Review) publish(e *xorm.Engine) error {
135135
Repo: review.Issue.Repo,
136136
Type: comm.Type,
137137
Content: comm.Content,
138+
Review: r,
138139
}, comm); err != nil {
139140
log.Warn("sendCreateCommentAction: %v", err)
140141
}

routers/repo/pull_review.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,12 @@ func SubmitReview(ctx *context.Context, form auth.SubmitReviewForm) {
174174
return
175175
}
176176
}
177+
178+
// Hotfix 1.10.0: make sure the review exists before creating the head comment
179+
if err = review.Publish(); err != nil {
180+
ctx.ServerError("Publish", err)
181+
return
182+
}
177183
comm, err := models.CreateComment(&models.CreateCommentOptions{
178184
Type: models.CommentTypeReview,
179185
Doer: ctx.User,
@@ -186,10 +192,6 @@ func SubmitReview(ctx *context.Context, form auth.SubmitReviewForm) {
186192
ctx.ServerError("CreateComment", err)
187193
return
188194
}
189-
if err = review.Publish(); err != nil {
190-
ctx.ServerError("Publish", err)
191-
return
192-
}
193195

194196
pr, err := issue.GetPullRequest()
195197
if err != nil {

0 commit comments

Comments
 (0)