Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-11-24 10:46:10 +01:00

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

Backport #20509
This commit is contained in:
6543 2022-07-28 22:18:49 +02:00 committed by GitHub
parent fa46d66835
commit 4ed32e79b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -902,11 +902,15 @@ func renderCode(ctx *context.Context) {
ctx.Data["PageIsViewCode"] = true
if ctx.Repo.Repository.IsEmpty {
reallyEmpty, err := ctx.Repo.GitRepo.IsEmpty()
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)
return