Parcourir la source

Fix possible panic when repository is empty (#20509)

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
tags/v1.18.0-rc0
Lunny Xiao il y a 1 an
Parent
révision
6554d5197f
Aucun compte lié à l'adresse e-mail de l'auteur
1 fichiers modifiés avec 8 ajouts et 4 suppressions
  1. 8
    4
      routers/web/repo/view.go

+ 8
- 4
routers/web/repo/view.go Voir le fichier

@@ -896,10 +896,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)

Chargement…
Annuler
Enregistrer