mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-27 22:23:50 +03:00
Fix possible panic when repository is empty (#20509)
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
parent
3f87525249
commit
6554d5197f
1 changed files with 8 additions and 4 deletions
|
@ -896,10 +896,14 @@ func renderCode(ctx *context.Context) {
|
||||||
ctx.Data["PageIsViewCode"] = true
|
ctx.Data["PageIsViewCode"] = true
|
||||||
|
|
||||||
if ctx.Repo.Repository.IsEmpty {
|
if ctx.Repo.Repository.IsEmpty {
|
||||||
reallyEmpty, err := ctx.Repo.GitRepo.IsEmpty()
|
reallyEmpty := true
|
||||||
if err != nil {
|
var err error
|
||||||
ctx.ServerError("GitRepo.IsEmpty", err)
|
if ctx.Repo.GitRepo != nil {
|
||||||
return
|
reallyEmpty, err = ctx.Repo.GitRepo.IsEmpty()
|
||||||
|
if err != nil {
|
||||||
|
ctx.ServerError("GitRepo.IsEmpty", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if reallyEmpty {
|
if reallyEmpty {
|
||||||
ctx.HTML(http.StatusOK, tplRepoEMPTY)
|
ctx.HTML(http.StatusOK, tplRepoEMPTY)
|
||||||
|
|
Loading…
Reference in a new issue