Fix possible panic when repository is empty (#20509) (#20526)

Backport #20509
tokarchuk/v1.17
6543 2 years ago committed by GitHub
parent fa46d66835
commit 4ed32e79b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      routers/web/repo/view.go

@ -902,10 +902,14 @@ func renderCode(ctx *context.Context) {
ctx.Data["PageIsViewCode"] = true
if ctx.Repo.Repository.IsEmpty {
reallyEmpty, err := ctx.Repo.GitRepo.IsEmpty()
if err != nil {
ctx.ServerError("GitRepo.IsEmpty", err)
return
reallyEmpty := true
var err error
if ctx.Repo.GitRepo != nil {
reallyEmpty, err = ctx.Repo.GitRepo.IsEmpty()
if err != nil {
ctx.ServerError("GitRepo.IsEmpty", err)
return
}
}
if reallyEmpty {
ctx.HTML(http.StatusOK, tplRepoEMPTY)

Loading…
Cancel
Save