diff --git a/models/issue_comment.go b/models/issue_comment.go index 4c337693d..6930c62e2 100644 --- a/models/issue_comment.go +++ b/models/issue_comment.go @@ -315,6 +315,12 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err if opts.Label != nil { LabelID = opts.Label.ID } + + var depId int64 = 0 + if opts.DependentIssue != nil { + depId = opts.DependentIssue.ID + } + comment := &Comment{ Type: opts.Type, PosterID: opts.Doer.ID, @@ -341,7 +347,6 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err // It seems to be inserted, but isnt. (Doesn't return an error, raw pasting // the sql query in a database console does work). But after the function // is called, there is no entry in the database. At least for type 12 and 13. - _, err = e.Insert(comment) if err != nil { return nil, err diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 1a21af460..c14c1076a 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -919,6 +919,23 @@ func NewComment(ctx *context.Context, form auth.CreateCommentForm) { (form.Status == "reopen" || form.Status == "close") && !(issue.IsPull && issue.PullRequest.HasMerged) { + // Check for open dependencies + if form.Status == "close"{ + + canbeClosed := models.IssueNoDependenciesLeft(issue) + + if !canbeClosed { + if issue.IsPull{ + ctx.Flash.Error("You need to close all issues blocking this pull request before you can merge it!") + ctx.Redirect(fmt.Sprintf("%s/pulls/%d", ctx.Repo.RepoLink, issue.Index)) + } else { + ctx.Flash.Error("You need to close all issues blocking this issue before you can close it!") + ctx.Redirect(fmt.Sprintf("%s/issues/%d", ctx.Repo.RepoLink, issue.Index)) + } + return + } + } + // Duplication and conflict check should apply to reopen pull request. var pr *models.PullRequest