Implemented not closing an issue if it has blocking dependencies
Signed-off-by: Konrad <konrad@kola-entertainments.de>
This commit is contained in:
parent
707551785f
commit
5927e13e53
|
|
@ -180,3 +180,23 @@ func issueDepExists(e Engine, issueID int64, depID int64) (exists bool, err erro
|
||||||
|
|
||||||
return
|
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
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -868,6 +868,18 @@ func NewComment(ctx *context.Context, form auth.CreateCommentForm) {
|
||||||
(form.Status == "reopen" || form.Status == "close") &&
|
(form.Status == "reopen" || form.Status == "close") &&
|
||||||
!(issue.IsPull && issue.PullRequest.HasMerged) {
|
!(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.
|
// Duplication and conflict check should apply to reopen pull request.
|
||||||
var pr *models.PullRequest
|
var pr *models.PullRequest
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user