diff options
author | Unknwon <u@gogs.io> | 2017-01-27 18:56:32 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2017-01-27 18:56:32 -0500 |
commit | e43479d948b1e3a71dd4488ee1419e45017ff5c1 (patch) | |
tree | ab3b19a44c305c145e6145cda8f709fe2c256a24 /modules/context/repo.go | |
parent | a2f2f7717ac7bcc887da3771adfefe67c346c512 (diff) |
Fix changed branch is not reflected when creating PR (#3604)
Diffstat (limited to 'modules/context/repo.go')
-rw-r--r-- | modules/context/repo.go | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/modules/context/repo.go b/modules/context/repo.go index b3d483df..59891f86 100644 --- a/modules/context/repo.go +++ b/modules/context/repo.go @@ -300,37 +300,6 @@ func RepoAssignment(args ...bool) macaron.Handler { 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 or have fored repository can propose a new pull request. - if ctx.Repo.IsWriter() || (ctx.IsSigned && ctx.User.HasForkedRepo(ctx.Repo.Repository.ID)) { - // 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 - } - } - } - ctx.Data["PullRequestCtx"] = ctx.Repo.PullRequest - if ctx.Query("go-get") == "1" { ctx.Data["GoGetImport"] = composeGoGetImport(owner.Name, repo.Name) prefix := setting.AppUrl + path.Join(owner.Name, repo.Name, "src", ctx.Repo.BranchName) @@ -443,6 +412,37 @@ func RepoRef() macaron.Handler { ctx.Data["IsViewTag"] = ctx.Repo.IsViewTag ctx.Data["IsViewCommit"] = ctx.Repo.IsViewCommit + if ctx.Repo.Repository.IsFork { + RetrieveBaseRepo(ctx, ctx.Repo.Repository) + if ctx.Written() { + return + } + } + + // People who have push access or have fored repository can propose a new pull request. + if ctx.Repo.IsWriter() || (ctx.IsSigned && ctx.User.HasForkedRepo(ctx.Repo.Repository.ID)) { + // Pull request is allowed if this is a fork repository + // and base repository accepts pull requests. + if ctx.Repo.Repository.BaseRepo != nil { + if ctx.Repo.Repository.BaseRepo.AllowsPulls() { + ctx.Data["BaseRepo"] = ctx.Repo.Repository.BaseRepo + ctx.Repo.PullRequest.BaseRepo = ctx.Repo.Repository.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 ctx.Repo.Repository.AllowsPulls() { + ctx.Data["BaseRepo"] = ctx.Repo.Repository + ctx.Repo.PullRequest.BaseRepo = ctx.Repo.Repository + ctx.Repo.PullRequest.Allowed = true + ctx.Repo.PullRequest.SameRepo = true + ctx.Repo.PullRequest.HeadInfo = ctx.Repo.BranchName + } + } + } + ctx.Data["PullRequestCtx"] = ctx.Repo.PullRequest + ctx.Repo.CommitsCount, err = ctx.Repo.Commit.CommitsCount() if err != nil { ctx.Handle(500, "CommitsCount", err) |