mirror of
https://github.com/go-gitea/gitea
synced 2025-09-17 14:18:15 +00:00
Move HasWiki to repository service package (#33912)
Move HasWiki out of the models package to avoid referencing the absolute wiki path directly.
This commit is contained in:
@@ -33,6 +33,7 @@ import (
|
||||
"code.gitea.io/gitea/services/forms"
|
||||
git_service "code.gitea.io/gitea/services/git"
|
||||
notify_service "code.gitea.io/gitea/services/notify"
|
||||
repo_service "code.gitea.io/gitea/services/repository"
|
||||
wiki_service "code.gitea.io/gitea/services/wiki"
|
||||
)
|
||||
|
||||
@@ -474,7 +475,7 @@ func Wiki(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if !ctx.Repo.Repository.HasWiki() {
|
||||
if !repo_service.HasWiki(ctx, ctx.Repo.Repository) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.wiki")
|
||||
ctx.HTML(http.StatusOK, tplWikiStart)
|
||||
return
|
||||
@@ -510,7 +511,7 @@ func Wiki(ctx *context.Context) {
|
||||
func WikiRevision(ctx *context.Context) {
|
||||
ctx.Data["CanWriteWiki"] = ctx.Repo.CanWrite(unit.TypeWiki) && !ctx.Repo.Repository.IsArchived
|
||||
|
||||
if !ctx.Repo.Repository.HasWiki() {
|
||||
if !repo_service.HasWiki(ctx, ctx.Repo.Repository) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.wiki")
|
||||
ctx.HTML(http.StatusOK, tplWikiStart)
|
||||
return
|
||||
@@ -540,7 +541,7 @@ func WikiRevision(ctx *context.Context) {
|
||||
|
||||
// WikiPages render wiki pages list page
|
||||
func WikiPages(ctx *context.Context) {
|
||||
if !ctx.Repo.Repository.HasWiki() {
|
||||
if !repo_service.HasWiki(ctx, ctx.Repo.Repository) {
|
||||
ctx.Redirect(ctx.Repo.RepoLink + "/wiki")
|
||||
return
|
||||
}
|
||||
@@ -648,7 +649,7 @@ func WikiRaw(ctx *context.Context) {
|
||||
func NewWiki(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.wiki.new_page")
|
||||
|
||||
if !ctx.Repo.Repository.HasWiki() {
|
||||
if !repo_service.HasWiki(ctx, ctx.Repo.Repository) {
|
||||
ctx.Data["title"] = "Home"
|
||||
}
|
||||
if ctx.FormString("title") != "" {
|
||||
@@ -701,7 +702,7 @@ func NewWikiPost(ctx *context.Context) {
|
||||
func EditWiki(ctx *context.Context) {
|
||||
ctx.Data["PageIsWikiEdit"] = true
|
||||
|
||||
if !ctx.Repo.Repository.HasWiki() {
|
||||
if !repo_service.HasWiki(ctx, ctx.Repo.Repository) {
|
||||
ctx.Redirect(ctx.Repo.RepoLink + "/wiki")
|
||||
return
|
||||
}
|
||||
|
@@ -16,6 +16,7 @@ import (
|
||||
"code.gitea.io/gitea/modules/web"
|
||||
"code.gitea.io/gitea/services/contexttest"
|
||||
"code.gitea.io/gitea/services/forms"
|
||||
repo_service "code.gitea.io/gitea/services/repository"
|
||||
wiki_service "code.gitea.io/gitea/services/wiki"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -240,7 +241,7 @@ func TestDefaultWikiBranch(t *testing.T) {
|
||||
|
||||
// repo with no wiki
|
||||
repoWithNoWiki := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 2})
|
||||
assert.False(t, repoWithNoWiki.HasWiki())
|
||||
assert.False(t, repo_service.HasWiki(t.Context(), repoWithNoWiki))
|
||||
assert.NoError(t, wiki_service.ChangeDefaultWikiBranch(t.Context(), repoWithNoWiki, "main"))
|
||||
|
||||
// repo with wiki
|
||||
|
Reference in New Issue
Block a user