Implemented not closing an issue if it has blocking dependencies

Signed-off-by: Konrad <konrad@kola-entertainments.de>
This commit is contained in:
Konrad Langenberg 2017-08-29 20:28:18 +02:00 committed by Konrad
parent 707551785f
commit 5927e13e53
2 changed files with 32 additions and 0 deletions

View File

@ -180,3 +180,23 @@ func issueDepExists(e Engine, issueID int64, depID int64) (exists bool, err erro
return
}
// check if issue can be closed
func IssueNoDependenciesLeft(issueID int64) bool{
var issueDeps []IssueDependency
err := x.Where("issue_id = ?", issueID).Find(&issueDeps)
for _, issueDep := range issueDeps{
issueDetails, _ := getIssueByID(x, issueDep.DependencyID)
if !issueDetails.IsClosed {
return false
}
}
if err != nil {
return false
}
return true
}

View File

@ -868,6 +868,18 @@ 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.ID)
if !canbeClosed {
ctx.Flash.Error("You need to close all issues blocking this issue!")
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