From 0e9bc2d4108ae32611e4fe65af493913c20d0279 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Sun, 6 Mar 2016 23:57:46 -0500 Subject: Fix pull request availability check --- routers/repo/issue.go | 16 +++++++++++++--- routers/repo/pull.go | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) (limited to 'routers') diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 02ccd2f9db..3a1049e65d 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -55,15 +55,21 @@ var ( func MustEnableIssues(ctx *middleware.Context) { if !ctx.Repo.Repository.EnableIssues { ctx.Handle(404, "MustEnableIssues", nil) + return } } func MustAllowPulls(ctx *middleware.Context) { if !ctx.Repo.Repository.AllowsPulls() { ctx.Handle(404, "MustAllowPulls", nil) + return } - ctx.Data["HasForkedRepo"] = ctx.IsSigned && ctx.User.HasForkedRepo(ctx.Repo.Repository.ID) + // User can send pull request if owns a forked repository. + if ctx.IsSigned && ctx.User.HasForkedRepo(ctx.Repo.Repository.ID) { + ctx.Repo.PullRequest.Allowed = true + ctx.Repo.PullRequest.HeadInfo = ctx.User.Name + ":" + ctx.Repo.BranchName + } } func RetrieveLabels(ctx *middleware.Context) { @@ -560,14 +566,18 @@ func ViewIssue(ctx *middleware.Context) { } if issue.IsPull { + MustAllowPulls(ctx) + if ctx.Written() { + return + } + ctx.Data["PageIsPullList"] = true + if err = issue.GetPullRequest(); err != nil { ctx.Handle(500, "GetPullRequest", err) return } - ctx.Data["PageIsPullList"] = true ctx.Data["PageIsPullConversation"] = true - ctx.Data["HasForkedRepo"] = ctx.IsSigned && ctx.User.HasForkedRepo(ctx.Repo.Repository.ID) } else { MustEnableIssues(ctx) if ctx.Written() { diff --git a/routers/repo/pull.go b/routers/repo/pull.go index c9d92297f6..fd4f6f69c5 100644 --- a/routers/repo/pull.go +++ b/routers/repo/pull.go @@ -462,7 +462,7 @@ func ParseCompareInfo(ctx *middleware.Context) (*models.User, *models.Repository } ctx.Data["HeadUser"] = headUser ctx.Data["HeadBranch"] = headBranch - ctx.Data["IsBetweenBranches"] = isSameRepo + ctx.Repo.PullRequest.SameRepo = isSameRepo // Check if base branch is valid. if !ctx.Repo.GitRepo.IsBranchExist(baseBranch) { -- cgit v1.2.3