@@ -177,6 +177,10 @@ func findWikiRepoCommit(ctx *context.Context) (*git.Repository, *git.Commit, err
177177 // ctx.Handle(500, "OpenRepository", err)
178178 return nil , nil , err
179179 }
180+ if ! wikiRepo .IsBranchExist ("master" ) {
181+ return wikiRepo , nil , nil
182+ }
183+
180184 commit , err := wikiRepo .GetBranchCommit ("master" )
181185 if err != nil {
182186 ctx .Handle (500 , "GetBranchCommit" , err )
@@ -190,6 +194,9 @@ func renderWikiPage(ctx *context.Context, isViewPage bool) (*git.Repository, *gi
190194 if err != nil {
191195 return nil , nil
192196 }
197+ if commit == nil {
198+ return wikiRepo , nil
199+ }
193200
194201 // Get page list.
195202 if isViewPage {
@@ -210,7 +217,7 @@ func renderWikiPage(ctx *context.Context, isViewPage bool) (*git.Repository, *gi
210217 }
211218 pages = append (pages , PageMeta {
212219 Name : models .ToWikiPageName (name ),
213- URL : models . ToWikiPageURL ( name ) ,
220+ URL : name ,
214221 })
215222 }
216223 }
@@ -308,6 +315,11 @@ func Wiki(ctx *context.Context) {
308315 if ctx .Written () {
309316 return
310317 }
318+ if entry == nil {
319+ ctx .Data ["Title" ] = ctx .Tr ("repo.wiki" )
320+ ctx .HTML (200 , tplWikiStart )
321+ return
322+ }
311323
312324 ename := entry .Name ()
313325 if ! markdown .IsMarkdownFile (ename ) {
@@ -362,7 +374,7 @@ func WikiPages(ctx *context.Context) {
362374 }
363375 pages = append (pages , PageMeta {
364376 Name : models .ToWikiPageName (name ),
365- URL : models . ToWikiPageURL ( name ) ,
377+ URL : name ,
366378 Updated : c .Author .When ,
367379 })
368380 }
@@ -480,7 +492,7 @@ func EditWikiPost(ctx *context.Context, form auth.NewWikiForm) {
480492 return
481493 }
482494
483- oldWikiPath := ctx .Params (":page" )
495+ oldWikiPath := models . ToWikiPageURL ( ctx .Params (":page" ) )
484496 newWikiPath := models .ToWikiPageURL (form .Title )
485497
486498 if err := ctx .Repo .Repository .EditWikiPage (ctx .User , oldWikiPath , newWikiPath , form .Content , form .Message ); err != nil {
@@ -493,7 +505,7 @@ func EditWikiPost(ctx *context.Context, form auth.NewWikiForm) {
493505
494506// DeleteWikiPagePost delete wiki page
495507func DeleteWikiPagePost (ctx * context.Context ) {
496- pageURL := ctx .Params (":page" )
508+ pageURL := models . ToWikiPageURL ( ctx .Params (":page" ) )
497509 if len (pageURL ) == 0 {
498510 pageURL = "Home"
499511 }
0 commit comments