From 878f684b9555bc20faa65122e30bc219262ce1cd Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Thu, 5 Mar 2020 15:15:11 +0000 Subject: [PATCH] Handle deleted base branch in PR Signed-off-by: Andrew Thornton --- routers/repo/pull.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/routers/repo/pull.go b/routers/repo/pull.go index e4fd19ee4987..64bd8a03b8c7 100644 --- a/routers/repo/pull.go +++ b/routers/repo/pull.go @@ -356,6 +356,16 @@ func PrepareViewPullInfo(ctx *context.Context, issue *models.Issue) *git.Compare return nil } defer baseGitRepo.Close() + + if !baseGitRepo.IsBranchExist(pull.BaseBranch) { + ctx.Data["IsPullRequestBroken"] = true + ctx.Data["BaseTarget"] = pull.BaseBranch + ctx.Data["HeadTarget"] = pull.HeadBranch + ctx.Data["NumCommits"] = 0 + ctx.Data["NumFiles"] = 0 + return nil + } + var headBranchExist bool var headBranchSha string // HeadRepo may be missing