Skip to content

Commit

Permalink
Fix possible panic when repository is empty (go-gitea#20509)
Browse files Browse the repository at this point in the history
Co-authored-by: wxiaoguang <[email protected]>
  • Loading branch information
2 people authored and 6543 committed Jul 28, 2022
1 parent a9a440e commit eff01b3
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions routers/web/repo/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit eff01b3

Please sign in to comment.