Implemented missing create table for Issue Dependencies table \
IssueNoDependenciesLeft now returns an error when something goes wrong ;
This commit is contained in:
parent
d1df4ec2b0
commit
dd24b9ff5a
|
|
@ -470,7 +470,12 @@ func UpdateIssuesCommit(doer *User, repo *Repository, commits []*PushCommit) err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for dependencies, if there aren't any, close it
|
// Check for dependencies, if there aren't any, close it
|
||||||
if IssueNoDependenciesLeft(issue) {
|
noDeps, err := IssueNoDependenciesLeft(issue)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if noDeps {
|
||||||
if err = issue.ChangeStatus(doer, repo, true); err != nil {
|
if err = issue.ChangeStatus(doer, repo, true); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -138,17 +138,17 @@ func (IssueDependencyIssue) TableName() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// IssueNoDependenciesLeft checks if issue can be closed
|
// IssueNoDependenciesLeft checks if issue can be closed
|
||||||
func IssueNoDependenciesLeft(issue *Issue) bool {
|
func IssueNoDependenciesLeft(issue *Issue) (exists bool, err error) {
|
||||||
|
|
||||||
exists, err := x.
|
exists, err = x.
|
||||||
Join("INNER", "issue", "issue.id = issue_dependency.dependency_id").
|
Join("INNER", "issue", "issue.id = issue_dependency.dependency_id").
|
||||||
Where("issue_dependency.issue_id = ?", issue.ID).
|
Where("issue_dependency.issue_id = ?", issue.ID).
|
||||||
And("issue.is_closed = ?", "0").
|
And("issue.is_closed = ?", "0").
|
||||||
Exist(&IssueDependencyIssue{})
|
Exist(&IssueDependencyIssue{})
|
||||||
|
|
||||||
if err != nil {
|
/*if err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}*/
|
||||||
|
|
||||||
return !exists
|
return !exists, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -117,6 +117,7 @@ func init() {
|
||||||
new(TrackedTime),
|
new(TrackedTime),
|
||||||
new(DeletedBranch),
|
new(DeletedBranch),
|
||||||
new(RepoIndexerStatus),
|
new(RepoIndexerStatus),
|
||||||
|
new(IssueDependency),
|
||||||
)
|
)
|
||||||
|
|
||||||
gonicNames := []string{"SSL", "UID"}
|
gonicNames := []string{"SSL", "UID"}
|
||||||
|
|
|
||||||
|
|
@ -937,7 +937,12 @@ func NewComment(ctx *context.Context, form auth.CreateCommentForm) {
|
||||||
!(issue.IsPull && issue.PullRequest.HasMerged) {
|
!(issue.IsPull && issue.PullRequest.HasMerged) {
|
||||||
|
|
||||||
// Check for open dependencies
|
// Check for open dependencies
|
||||||
if form.Status == "close" && !models.IssueNoDependenciesLeft(issue) {
|
noDeps, err := models.IssueNoDependenciesLeft(issue)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if form.Status == "close" && !noDeps {
|
||||||
if issue.IsPull {
|
if issue.IsPull {
|
||||||
ctx.Flash.Error("You need to close all issues blocking this pull request before you can merge it!")
|
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))
|
ctx.Redirect(fmt.Sprintf("%s/pulls/%d", ctx.Repo.RepoLink, issue.Index))
|
||||||
|
|
|
||||||
|
|
@ -455,7 +455,12 @@ func MergePullRequest(ctx *context.Context) {
|
||||||
pr.Issue = issue
|
pr.Issue = issue
|
||||||
pr.Issue.Repo = ctx.Repo.Repository
|
pr.Issue.Repo = ctx.Repo.Repository
|
||||||
|
|
||||||
if !models.IssueNoDependenciesLeft(issue) {
|
noDeps, err := models.IssueNoDependenciesLeft(issue)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if !noDeps {
|
||||||
ctx.Flash.Error("You need to close all issues blocking this pull request before you can merge it!")
|
ctx.Flash.Error("You need to close all issues blocking this pull request before you can merge it!")
|
||||||
ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(pr.Index))
|
ctx.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(pr.Index))
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user