Skip to content

Commit 3502730

Browse files
authored
Handle deleted base branch in PR (#10618)
Signed-off-by: Andrew Thornton <[email protected]>
1 parent ae452d0 commit 3502730

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

routers/repo/pull.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,16 @@ func PrepareViewPullInfo(ctx *context.Context, issue *models.Issue) *git.Compare
356356
return nil
357357
}
358358
defer baseGitRepo.Close()
359+
360+
if !baseGitRepo.IsBranchExist(pull.BaseBranch) {
361+
ctx.Data["IsPullRequestBroken"] = true
362+
ctx.Data["BaseTarget"] = pull.BaseBranch
363+
ctx.Data["HeadTarget"] = pull.HeadBranch
364+
ctx.Data["NumCommits"] = 0
365+
ctx.Data["NumFiles"] = 0
366+
return nil
367+
}
368+
359369
var headBranchExist bool
360370
var headBranchSha string
361371
// HeadRepo may be missing

0 commit comments

Comments
 (0)