@@ -33,6 +33,7 @@ import (
3333 "code.gitea.io/gitea/services/forms"
3434 git_service "code.gitea.io/gitea/services/git"
3535 notify_service "code.gitea.io/gitea/services/notify"
36+ repo_service "code.gitea.io/gitea/services/repository"
3637 wiki_service "code.gitea.io/gitea/services/wiki"
3738)
3839
@@ -474,12 +475,7 @@ func Wiki(ctx *context.Context) {
474475 return
475476 }
476477
477- hasWiki , err := gitrepo .IsRepositoryExist (ctx , ctx .Repo .Repository .WikiStorageRepo ())
478- if err != nil {
479- ctx .ServerError ("IsWikiRepositoryExist" , err )
480- return
481- }
482- if ! hasWiki {
478+ if ! repo_service .HasWiki (ctx , ctx .Repo .Repository ) {
483479 ctx .Data ["Title" ] = ctx .Tr ("repo.wiki" )
484480 ctx .HTML (http .StatusOK , tplWikiStart )
485481 return
@@ -515,12 +511,7 @@ func Wiki(ctx *context.Context) {
515511func WikiRevision (ctx * context.Context ) {
516512 ctx .Data ["CanWriteWiki" ] = ctx .Repo .CanWrite (unit .TypeWiki ) && ! ctx .Repo .Repository .IsArchived
517513
518- hasWiki , err := gitrepo .IsRepositoryExist (ctx , ctx .Repo .Repository .WikiStorageRepo ())
519- if err != nil {
520- ctx .ServerError ("IsWikiRepositoryExist" , err )
521- return
522- }
523- if ! hasWiki {
514+ if ! repo_service .HasWiki (ctx , ctx .Repo .Repository ) {
524515 ctx .Data ["Title" ] = ctx .Tr ("repo.wiki" )
525516 ctx .HTML (http .StatusOK , tplWikiStart )
526517 return
@@ -550,12 +541,7 @@ func WikiRevision(ctx *context.Context) {
550541
551542// WikiPages render wiki pages list page
552543func WikiPages (ctx * context.Context ) {
553- hasWiki , err := gitrepo .IsRepositoryExist (ctx , ctx .Repo .Repository .WikiStorageRepo ())
554- if err != nil {
555- ctx .ServerError ("IsWikiRepositoryExist" , err )
556- return
557- }
558- if ! hasWiki {
544+ if ! repo_service .HasWiki (ctx , ctx .Repo .Repository ) {
559545 ctx .Redirect (ctx .Repo .RepoLink + "/wiki" )
560546 return
561547 }
@@ -663,12 +649,7 @@ func WikiRaw(ctx *context.Context) {
663649func NewWiki (ctx * context.Context ) {
664650 ctx .Data ["Title" ] = ctx .Tr ("repo.wiki.new_page" )
665651
666- hasWiki , err := gitrepo .IsRepositoryExist (ctx , ctx .Repo .Repository .WikiStorageRepo ())
667- if err != nil {
668- ctx .ServerError ("IsWikiRepositoryExist" , err )
669- return
670- }
671- if ! hasWiki {
652+ if ! repo_service .HasWiki (ctx , ctx .Repo .Repository ) {
672653 ctx .Data ["title" ] = "Home"
673654 }
674655 if ctx .FormString ("title" ) != "" {
@@ -721,12 +702,7 @@ func NewWikiPost(ctx *context.Context) {
721702func EditWiki (ctx * context.Context ) {
722703 ctx .Data ["PageIsWikiEdit" ] = true
723704
724- hasWiki , err := gitrepo .IsRepositoryExist (ctx , ctx .Repo .Repository .WikiStorageRepo ())
725- if err != nil {
726- ctx .ServerError ("IsWikiRepositoryExist" , err )
727- return
728- }
729- if ! hasWiki {
705+ if ! repo_service .HasWiki (ctx , ctx .Repo .Repository ) {
730706 ctx .Redirect (ctx .Repo .RepoLink + "/wiki" )
731707 return
732708 }
0 commit comments