summaryrefslogtreecommitdiffstats
path: root/routers/repo/issue.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2016-03-06 23:57:46 -0500
committerUnknwon <u@gogs.io>2016-03-06 23:57:46 -0500
commit0e9bc2d4108ae32611e4fe65af493913c20d0279 (patch)
tree58addb3ebbc98174543f5fc44bd60599941e3dd1 /routers/repo/issue.go
parent0ea0c5ec4f24f0fc5ef3231085c74b33a16f98ec (diff)
downloadgitea-0e9bc2d4108ae32611e4fe65af493913c20d0279.tar.gz
gitea-0e9bc2d4108ae32611e4fe65af493913c20d0279.zip
Fix pull request availability check
Diffstat (limited to 'routers/repo/issue.go')
-rw-r--r--routers/repo/issue.go16
1 files changed, 13 insertions, 3 deletions
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() {