Simplified checking for open dependencies

Signed-off-by: Konrad <konrad@kola-entertainments.de>
This commit is contained in:
Konrad Langenberg 2017-09-24 16:29:25 +02:00 committed by Konrad
parent 837c917798
commit fe8181af73
2 changed files with 9 additions and 12 deletions

View File

@ -139,7 +139,7 @@ func IssueNoDependenciesLeft(issue *Issue) bool {
var issueDeps []IssueDependencyIssue
err := x.Join("INNER", "issue", "issue.id = issue_dependency.issue_id").Find(&issueDeps)
if err != nil {
return false
}

View File

@ -920,18 +920,15 @@ func NewComment(ctx *context.Context, form auth.CreateCommentForm) {
!(issue.IsPull && issue.PullRequest.HasMerged) {
// Check for open dependencies
if form.Status == "close" {
if models.IssueNoDependenciesLeft(issue) {
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
if form.Status == "close" && models.IssueNoDependenciesLeft(issue) {
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.