Skip to content

Commit c295ff2

Browse files
unknwonlunny
authored andcommitted
Fix changed branch is not reflected when creating PR (#3604)
1 parent 4c12e2a commit c295ff2

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

modules/context/repo.go

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -323,37 +323,6 @@ func RepoAssignment(args ...bool) macaron.Handler {
323323
ctx.Data["BranchName"] = ctx.Repo.BranchName
324324
ctx.Data["CommitID"] = ctx.Repo.CommitID
325325

326-
if repo.IsFork {
327-
RetrieveBaseRepo(ctx, repo)
328-
if ctx.Written() {
329-
return
330-
}
331-
}
332-
333-
// People who have push access or have fored repository can propose a new pull request.
334-
if ctx.Repo.IsWriter() || (ctx.IsSigned && ctx.User.HasForkedRepo(ctx.Repo.Repository.ID)) {
335-
// Pull request is allowed if this is a fork repository
336-
// and base repository accepts pull requests.
337-
if repo.BaseRepo != nil {
338-
if repo.BaseRepo.AllowsPulls() {
339-
ctx.Data["BaseRepo"] = repo.BaseRepo
340-
ctx.Repo.PullRequest.BaseRepo = repo.BaseRepo
341-
ctx.Repo.PullRequest.Allowed = true
342-
ctx.Repo.PullRequest.HeadInfo = ctx.Repo.Owner.Name + ":" + ctx.Repo.BranchName
343-
}
344-
} else {
345-
// Or, this is repository accepts pull requests between branches.
346-
if repo.AllowsPulls() {
347-
ctx.Data["BaseRepo"] = repo
348-
ctx.Repo.PullRequest.BaseRepo = repo
349-
ctx.Repo.PullRequest.Allowed = true
350-
ctx.Repo.PullRequest.SameRepo = true
351-
ctx.Repo.PullRequest.HeadInfo = ctx.Repo.BranchName
352-
}
353-
}
354-
}
355-
ctx.Data["PullRequestCtx"] = ctx.Repo.PullRequest
356-
357326
if ctx.Query("go-get") == "1" {
358327
ctx.Data["GoGetImport"] = composeGoGetImport(owner.Name, repo.Name)
359328
prefix := setting.AppURL + path.Join(owner.Name, repo.Name, "src", ctx.Repo.BranchName)
@@ -466,6 +435,37 @@ func RepoRef() macaron.Handler {
466435
ctx.Data["IsViewTag"] = ctx.Repo.IsViewTag
467436
ctx.Data["IsViewCommit"] = ctx.Repo.IsViewCommit
468437

438+
if ctx.Repo.Repository.IsFork {
439+
RetrieveBaseRepo(ctx, ctx.Repo.Repository)
440+
if ctx.Written() {
441+
return
442+
}
443+
}
444+
445+
// People who have push access or have fored repository can propose a new pull request.
446+
if ctx.Repo.IsWriter() || (ctx.IsSigned && ctx.User.HasForkedRepo(ctx.Repo.Repository.ID)) {
447+
// Pull request is allowed if this is a fork repository
448+
// and base repository accepts pull requests.
449+
if ctx.Repo.Repository.BaseRepo != nil {
450+
if ctx.Repo.Repository.BaseRepo.AllowsPulls() {
451+
ctx.Data["BaseRepo"] = ctx.Repo.Repository.BaseRepo
452+
ctx.Repo.PullRequest.BaseRepo = ctx.Repo.Repository.BaseRepo
453+
ctx.Repo.PullRequest.Allowed = true
454+
ctx.Repo.PullRequest.HeadInfo = ctx.Repo.Owner.Name + ":" + ctx.Repo.BranchName
455+
}
456+
} else {
457+
// Or, this is repository accepts pull requests between branches.
458+
if ctx.Repo.Repository.AllowsPulls() {
459+
ctx.Data["BaseRepo"] = ctx.Repo.Repository
460+
ctx.Repo.PullRequest.BaseRepo = ctx.Repo.Repository
461+
ctx.Repo.PullRequest.Allowed = true
462+
ctx.Repo.PullRequest.SameRepo = true
463+
ctx.Repo.PullRequest.HeadInfo = ctx.Repo.BranchName
464+
}
465+
}
466+
}
467+
ctx.Data["PullRequestCtx"] = ctx.Repo.PullRequest
468+
469469
ctx.Repo.CommitsCount, err = ctx.Repo.Commit.CommitsCount()
470470
if err != nil {
471471
ctx.Handle(500, "CommitsCount", err)

0 commit comments

Comments
 (0)