diff --git a/routers/repo/pull.go b/routers/repo/pull.go index c8c35ae917f39..1e2d60d727b25 100644 --- a/routers/repo/pull.go +++ b/routers/repo/pull.go @@ -354,6 +354,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