Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix for review actions and notifications (1.10.0) #8965

Merged
merged 2 commits into from
Nov 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions models/issue_comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,10 @@ func sendCreateCommentAction(e *xorm.Session, opts *CreateCommentOptions, commen
switch opts.Type {
case CommentTypeCode:
if comment.ReviewID != 0 {
// Hotfix for 1.10.0 as the Review object has not yet been committed in the other session
if opts.Review != nil {
comment.Review = opts.Review
}
if comment.Review == nil {
if err := comment.loadReview(e); err != nil {
return err
Expand Down Expand Up @@ -596,6 +600,12 @@ func sendCreateCommentAction(e *xorm.Session, opts *CreateCommentOptions, commen
if err = opts.Issue.updateClosedNum(e); err != nil {
return err
}
case CommentTypeReview:
// Hotfix for 1.10.0; make sure a dashboard entry is created
if opts.Content == "" {
return nil
}
act.OpType = ActionCommentIssue
}
// update the issue's updated_unix column
if err = updateIssueCols(e, opts.Issue, "updated_unix"); err != nil {
Expand Down Expand Up @@ -751,11 +761,12 @@ func createIssueDependencyComment(e *xorm.Session, doer *User, issue *Issue, dep

// CreateCommentOptions defines options for creating comment
type CreateCommentOptions struct {
Type CommentType
Doer *User
Repo *Repository
Issue *Issue
Label *Label
Type CommentType
Doer *User
Repo *Repository
Issue *Issue
Label *Label
Review *Review

DependentIssueID int64
OldMilestoneID int64
Expand Down
1 change: 1 addition & 0 deletions models/review.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ func (r *Review) publish(e *xorm.Engine) error {
Repo: review.Issue.Repo,
Type: comm.Type,
Content: comm.Content,
Review: r,
}, comm); err != nil {
log.Warn("sendCreateCommentAction: %v", err)
}
Expand Down
10 changes: 6 additions & 4 deletions routers/repo/pull_review.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,12 @@ func SubmitReview(ctx *context.Context, form auth.SubmitReviewForm) {
return
}
}

// Hotfix 1.10.0: make sure the review exists before creating the head comment
if err = review.Publish(); err != nil {
ctx.ServerError("Publish", err)
return
}
comm, err := models.CreateComment(&models.CreateCommentOptions{
Type: models.CommentTypeReview,
Doer: ctx.User,
Expand All @@ -186,10 +192,6 @@ func SubmitReview(ctx *context.Context, form auth.SubmitReviewForm) {
ctx.ServerError("CreateComment", err)
return
}
if err = review.Publish(); err != nil {
ctx.ServerError("Publish", err)
return
}

pr, err := issue.GetPullRequest()
if err != nil {
Expand Down