Implemented missing create table for Issue Dependencies table \

IssueNoDependenciesLeft now returns an error when something goes wrong
;
This commit is contained in:
Konrad 2017-11-01 16:16:49 +01:00
parent d1df4ec2b0
commit dd24b9ff5a
No known key found for this signature in database
GPG Key ID: F40E70337AB24C9B
5 changed files with 24 additions and 8 deletions

View File

@ -470,7 +470,12 @@ func UpdateIssuesCommit(doer *User, repo *Repository, commits []*PushCommit) err
}
// 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 {
return err
}

View File

@ -138,17 +138,17 @@ func (IssueDependencyIssue) TableName() string {
}
// 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").
Where("issue_dependency.issue_id = ?", issue.ID).
And("issue.is_closed = ?", "0").
Exist(&IssueDependencyIssue{})
if err != nil {
/*if err != nil {
return false
}
}*/
return !exists
return !exists, err
}

View File

@ -117,6 +117,7 @@ func init() {
new(TrackedTime),
new(DeletedBranch),
new(RepoIndexerStatus),
new(IssueDependency),
)
gonicNames := []string{"SSL", "UID"}

View File

@ -937,7 +937,12 @@ func NewComment(ctx *context.Context, form auth.CreateCommentForm) {
!(issue.IsPull && issue.PullRequest.HasMerged) {
// 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 {
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))

View File

@ -455,7 +455,12 @@ func MergePullRequest(ctx *context.Context) {
pr.Issue = issue
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.Redirect(ctx.Repo.RepoLink + "/pulls/" + com.ToStr(pr.Index))
return