Fix the bug: no wiki page can be created if the repo didn't have any page yet. (#17894)

This commit is contained in:
wxiaoguang 2021-12-04 03:46:11 +08:00 committed by GitHub
parent 1a78e23355
commit aa79738a66
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -409,12 +409,6 @@ func Wiki(ctx *context.Context) {
ctx.Data["PageIsWiki"] = true
ctx.Data["CanWriteWiki"] = ctx.Repo.CanWrite(unit.TypeWiki) && !ctx.Repo.Repository.IsArchived
if !ctx.Repo.Repository.HasWiki() {
ctx.Data["Title"] = ctx.Tr("repo.wiki")
ctx.HTML(http.StatusOK, tplWikiStart)
return
}
switch ctx.FormString("action") {
case "_pages":
WikiPages(ctx)
@ -438,6 +432,12 @@ func Wiki(ctx *context.Context) {
return
}
if !ctx.Repo.Repository.HasWiki() {
ctx.Data["Title"] = ctx.Tr("repo.wiki")
ctx.HTML(http.StatusOK, tplWikiStart)
return
}
wikiRepo, entry := renderViewPage(ctx)
defer func() {
if wikiRepo != nil {