From 24fa56830f23188c4b8997de5fdb8dff71b581a8 Mon Sep 17 00:00:00 2001 From: Mario Lubenka Date: Sun, 11 Aug 2019 22:32:03 +0200 Subject: [PATCH] Enable switching to a different source branch when PR already exists (#7823) Signed-off-by: Mario Lubenka --- routers/repo/compare.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/routers/repo/compare.go b/routers/repo/compare.go index a85084791d3..193255ca6ca 100644 --- a/routers/repo/compare.go +++ b/routers/repo/compare.go @@ -292,6 +292,13 @@ func CompareDiff(ctx *context.Context) { } if ctx.Data["PageIsComparePull"] == true { + headBranches, err := headGitRepo.GetBranches() + if err != nil { + ctx.ServerError("GetBranches", err) + return + } + ctx.Data["HeadBranches"] = headBranches + pr, err := models.GetUnmergedPullRequest(headRepo.ID, ctx.Repo.Repository.ID, headBranch, baseBranch) if err != nil { if !models.IsErrPullRequestNotExist(err) { @@ -312,13 +319,6 @@ func CompareDiff(ctx *context.Context) { return } } - - headBranches, err := headGitRepo.GetBranches() - if err != nil { - ctx.ServerError("GetBranches", err) - return - } - ctx.Data["HeadBranches"] = headBranches } beforeCommitID := ctx.Data["BeforeCommitID"].(string) afterCommitID := ctx.Data["AfterCommitID"].(string)