diff options
author | Unknwon <u@gogs.io> | 2016-03-06 23:57:46 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2016-03-06 23:57:46 -0500 |
commit | 0e9bc2d4108ae32611e4fe65af493913c20d0279 (patch) | |
tree | 58addb3ebbc98174543f5fc44bd60599941e3dd1 /modules/middleware/repo.go | |
parent | 0ea0c5ec4f24f0fc5ef3231085c74b33a16f98ec (diff) |
Fix pull request availability check
Diffstat (limited to 'modules/middleware/repo.go')
-rw-r--r-- | modules/middleware/repo.go | 59 |
1 files changed, 32 insertions, 27 deletions
diff --git a/modules/middleware/repo.go b/modules/middleware/repo.go index 3e1835f5..f96b87d4 100644 --- a/modules/middleware/repo.go +++ b/modules/middleware/repo.go @@ -142,32 +142,6 @@ func RepoAssignment(args ...bool) macaron.Handler { ctx.Data["IsRepositoryAdmin"] = ctx.Repo.IsAdmin() ctx.Data["IsRepositoryWriter"] = ctx.Repo.IsWriter() - if repo.IsFork { - RetrieveBaseRepo(ctx, repo) - if ctx.Written() { - return - } - } - - // People who have push access and propose a new pull request. - if ctx.Repo.IsWriter() { - // Pull request is allowed if this is a fork repository - // and base repository accepts pull requests. - if repo.BaseRepo != nil { - if repo.BaseRepo.AllowsPulls() { - ctx.Data["CanPullRequest"] = true - ctx.Data["BaseRepo"] = repo.BaseRepo - } - } else { - // Or, this is repository accepts pull requests between branches. - if repo.AllowsPulls() { - ctx.Data["CanPullRequest"] = true - ctx.Data["BaseRepo"] = repo - ctx.Data["IsBetweenBranches"] = true - } - } - } - ctx.Data["DisableSSH"] = setting.SSH.Disabled ctx.Data["CloneLink"] = repo.CloneLink() ctx.Data["WikiCloneLink"] = repo.WikiCloneLink() @@ -209,10 +183,41 @@ func RepoAssignment(args ...bool) macaron.Handler { ctx.Repo.BranchName = brs[0] } } - ctx.Data["BranchName"] = ctx.Repo.BranchName ctx.Data["CommitID"] = ctx.Repo.CommitID + if repo.IsFork { + RetrieveBaseRepo(ctx, repo) + if ctx.Written() { + return + } + } + + // People who have push access and propose a new pull request. + if ctx.Repo.IsWriter() { + // Pull request is allowed if this is a fork repository + // and base repository accepts pull requests. + if repo.BaseRepo != nil { + if repo.BaseRepo.AllowsPulls() { + ctx.Data["BaseRepo"] = repo.BaseRepo + ctx.Repo.PullRequest.BaseRepo = repo.BaseRepo + ctx.Repo.PullRequest.Allowed = true + ctx.Repo.PullRequest.HeadInfo = ctx.Repo.Owner.Name + ":" + ctx.Repo.BranchName + } + } else { + // Or, this is repository accepts pull requests between branches. + if repo.AllowsPulls() { + ctx.Data["BaseRepo"] = repo + ctx.Repo.PullRequest.BaseRepo = repo + ctx.Repo.PullRequest.Allowed = true + ctx.Repo.PullRequest.SameRepo = true + ctx.Repo.PullRequest.HeadInfo = ctx.Repo.BranchName + } + } + } + fmt.Println(222222, ctx.Repo.PullRequest) + ctx.Data["PullRequestCtx"] = ctx.Repo.PullRequest + if ctx.Query("go-get") == "1" { ctx.Data["GoGetImport"] = path.Join(setting.Domain, setting.AppSubUrl, owner.Name, repo.Name) prefix := setting.AppUrl + path.Join(owner.Name, repo.Name, "src", ctx.Repo.BranchName) |