@@ -6,6 +6,7 @@ package repo
66
77import (
88 "bytes"
9+ gocontext "context"
910 "fmt"
1011 "io"
1112 "net/http"
@@ -645,22 +646,32 @@ func WikiPages(ctx *context.Context) {
645646 return
646647 }
647648
648- entries , err := commit .ListEntries ()
649+ treePath := "" // To support list sub folders' pages in the future
650+ tree , err := commit .SubTree (treePath )
651+ if err != nil {
652+ ctx .ServerError ("SubTree" , err )
653+ return
654+ }
655+
656+ allEntries , err := tree .ListEntries ()
649657 if err != nil {
650658 ctx .ServerError ("ListEntries" , err )
651659 return
652660 }
661+ allEntries .CustomSort (base .NaturalSortLess )
662+
663+ entries , _ , err := allEntries .GetCommitsInfo (gocontext .Context (ctx ), commit , treePath )
664+ if err != nil {
665+ ctx .ServerError ("GetCommitsInfo" , err )
666+ return
667+ }
668+
653669 pages := make ([]PageMeta , 0 , len (entries ))
654670 for _ , entry := range entries {
655- if ! entry .IsRegular () {
671+ if ! entry .Entry . IsRegular () {
656672 continue
657673 }
658- c , err := wikiRepo .GetCommitByPath (entry .Name ())
659- if err != nil {
660- ctx .ServerError ("GetCommit" , err )
661- return
662- }
663- wikiName , err := wiki_service .GitPathToWebPath (entry .Name ())
674+ wikiName , err := wiki_service .GitPathToWebPath (entry .Entry .Name ())
664675 if err != nil {
665676 if repo_model .IsErrWikiInvalidFileName (err ) {
666677 continue
@@ -672,8 +683,8 @@ func WikiPages(ctx *context.Context) {
672683 pages = append (pages , PageMeta {
673684 Name : displayName ,
674685 SubURL : wiki_service .WebPathToURLPath (wikiName ),
675- GitEntryName : entry .Name (),
676- UpdatedUnix : timeutil .TimeStamp (c .Author .When .Unix ()),
686+ GitEntryName : entry .Entry . Name (),
687+ UpdatedUnix : timeutil .TimeStamp (entry . Commit .Author .When .Unix ()),
677688 })
678689 }
679690 ctx .Data ["Pages" ] = pages
0 commit comments