mirror of
https://github.com/go-gitea/gitea.git
synced 2025-06-29 10:05:02 +02:00
fix: deal with empty repo
This commit is contained in:
parent
eaf266a635
commit
26b87561b6
@ -13,6 +13,7 @@ import (
|
|||||||
"code.gitea.io/gitea/modules/base"
|
"code.gitea.io/gitea/modules/base"
|
||||||
"code.gitea.io/gitea/modules/context"
|
"code.gitea.io/gitea/modules/context"
|
||||||
"code.gitea.io/gitea/modules/convert"
|
"code.gitea.io/gitea/modules/convert"
|
||||||
|
"code.gitea.io/gitea/modules/git"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
"code.gitea.io/gitea/modules/util"
|
"code.gitea.io/gitea/modules/util"
|
||||||
)
|
)
|
||||||
@ -46,21 +47,26 @@ func List(ctx *context.Context) {
|
|||||||
ctx.Data["Title"] = ctx.Tr("repo.actions")
|
ctx.Data["Title"] = ctx.Tr("repo.actions")
|
||||||
ctx.Data["PageIsActions"] = true
|
ctx.Data["PageIsActions"] = true
|
||||||
|
|
||||||
defaultBranch, err := ctx.Repo.GitRepo.GetDefaultBranch()
|
var workflows git.Entries
|
||||||
if err != nil {
|
if empty, err := ctx.Repo.GitRepo.IsEmpty(); err != nil {
|
||||||
ctx.Error(http.StatusInternalServerError, err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
commit, err := ctx.Repo.GitRepo.GetBranchCommit(defaultBranch)
|
|
||||||
if err != nil {
|
|
||||||
ctx.Error(http.StatusInternalServerError, err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
workflows, err := actions.ListWorkflows(commit)
|
|
||||||
if err != nil {
|
|
||||||
ctx.Error(http.StatusInternalServerError, err.Error())
|
ctx.Error(http.StatusInternalServerError, err.Error())
|
||||||
return
|
return
|
||||||
|
} else if !empty {
|
||||||
|
defaultBranch, err := ctx.Repo.GitRepo.GetDefaultBranch()
|
||||||
|
if err != nil {
|
||||||
|
ctx.Error(http.StatusInternalServerError, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
commit, err := ctx.Repo.GitRepo.GetBranchCommit(defaultBranch)
|
||||||
|
if err != nil {
|
||||||
|
ctx.Error(http.StatusInternalServerError, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
workflows, err = actions.ListWorkflows(commit)
|
||||||
|
if err != nil {
|
||||||
|
ctx.Error(http.StatusInternalServerError, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.Data["workflows"] = workflows
|
ctx.Data["workflows"] = workflows
|
||||||
|
Loading…
x
Reference in New Issue
Block a user