Compare commits

...

2 Commits

Author SHA1 Message Date
6543
9aa13c585e Fix possible panic when repository is empty (#20509) (#20527) 2022-07-28 20:02:53 +01:00
Tyrone Yeh
eeaa9250e0 Fix org label open count, including close count issue (#20365) 2022-07-14 03:41:56 +01:00
2 changed files with 10 additions and 4 deletions

View File

@@ -17,6 +17,7 @@ import (
"code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/db"
user_model "code.gitea.io/gitea/models/user" user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/timeutil" "code.gitea.io/gitea/modules/timeutil"
"code.gitea.io/gitea/modules/util"
"xorm.io/builder" "xorm.io/builder"
) )
@@ -104,6 +105,7 @@ func (label *Label) CalOpenOrgIssues(repoID, labelID int64) {
counts, _ := CountIssuesByRepo(&IssuesOptions{ counts, _ := CountIssuesByRepo(&IssuesOptions{
RepoID: repoID, RepoID: repoID,
LabelIDs: []int64{labelID}, LabelIDs: []int64{labelID},
IsClosed: util.OptionalBoolFalse,
}) })
for _, count := range counts { for _, count := range counts {

View File

@@ -856,11 +856,15 @@ 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
var err error
if ctx.Repo.GitRepo != nil {
reallyEmpty, err = ctx.Repo.GitRepo.IsEmpty()
if err != nil { if err != nil {
ctx.ServerError("GitRepo.IsEmpty", err) ctx.ServerError("GitRepo.IsEmpty", err)
return return
} }
}
if reallyEmpty { if reallyEmpty {
ctx.HTML(http.StatusOK, tplRepoEMPTY) ctx.HTML(http.StatusOK, tplRepoEMPTY)
return return