Skip to content

Commit 9a929ad

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

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
@@ -354,6 +354,16 @@ func PrepareViewPullInfo(ctx *context.Context, issue *models.Issue) *git.Compare
354354
return nil
355355
}
356356
defer baseGitRepo.Close()
357+
358+
if !baseGitRepo.IsBranchExist(pull.BaseBranch) {
359+
ctx.Data["IsPullRequestBroken"] = true
360+
ctx.Data["BaseTarget"] = pull.BaseBranch
361+
ctx.Data["HeadTarget"] = pull.HeadBranch
362+
ctx.Data["NumCommits"] = 0
363+
ctx.Data["NumFiles"] = 0
364+
return nil
365+
}
366+
357367
var headBranchExist bool
358368
var headBranchSha string
359369
// HeadRepo may be missing

0 commit comments

Comments
 (0)