From a9607ed7206ab24bbde4e062d42833816f0187a2 Mon Sep 17 00:00:00 2001 From: Konrad Langenberg Date: Tue, 29 Aug 2017 22:32:29 +0200 Subject: [PATCH] Implemented Dependencies for pull requests. Signed-off-by: Konrad --- routers/repo/issue.go | 9 +++++++-- routers/repo/pull.go | 8 ++++++++ templates/repo/issue/view_content/sidebar.tmpl | 16 ++++++++++++++-- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/routers/repo/issue.go b/routers/repo/issue.go index ff51b6aaa..d280717ab 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -874,8 +874,13 @@ func NewComment(ctx *context.Context, form auth.CreateCommentForm) { 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)) + 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 } } diff --git a/routers/repo/pull.go b/routers/repo/pull.go index ad4a01ec9..7b3296403 100644 --- a/routers/repo/pull.go +++ b/routers/repo/pull.go @@ -428,6 +428,14 @@ func MergePullRequest(ctx *context.Context) { pr.Issue = issue pr.Issue.Repo = ctx.Repo.Repository + canbeClosed := models.IssueNoDependenciesLeft(issue.ID) + + if !canbeClosed { + 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 + } + if err = pr.Merge(ctx.User, ctx.Repo.GitRepo); err != nil { ctx.Handle(500, "Merge", err) return diff --git a/templates/repo/issue/view_content/sidebar.tmpl b/templates/repo/issue/view_content/sidebar.tmpl index 5daa83453..27f17c314 100644 --- a/templates/repo/issue/view_content/sidebar.tmpl +++ b/templates/repo/issue/view_content/sidebar.tmpl @@ -128,7 +128,13 @@ {{.i18n.Tr "repo.issues.dependency.title"}}
{{if .BlockedByDependencies}} - Closing this issue is blocked by: + + {{if .Issue.IsPull}} + Closing this pull request is blocked by: + {{else}} + Closing this issue is blocked by: + {{end}} +
{{range .BlockedByDependencies}}
@@ -155,7 +161,13 @@ {{if .BlockingDependencies}}
- This issue blocks closing of the following issues: + + {{if .Issue.IsPull}} + This pull request blocks closing of the following issues: + {{else}} + This issue blocks closing of the following issues: + {{end}} + {{range .BlockingDependencies}}