@@ -6,6 +6,7 @@ package repo
6
6
7
7
import (
8
8
"bytes"
9
+ gocontext "context"
9
10
"fmt"
10
11
"io"
11
12
"net/http"
@@ -651,22 +652,32 @@ func WikiPages(ctx *context.Context) {
651
652
return
652
653
}
653
654
654
- entries , err := commit .ListEntries ()
655
+ treePath := "" // To support list sub folders' pages in the future
656
+ tree , err := commit .SubTree (treePath )
657
+ if err != nil {
658
+ ctx .ServerError ("SubTree" , err )
659
+ return
660
+ }
661
+
662
+ allEntries , err := tree .ListEntries ()
655
663
if err != nil {
656
664
ctx .ServerError ("ListEntries" , err )
657
665
return
658
666
}
667
+ allEntries .CustomSort (base .NaturalSortLess )
668
+
669
+ entries , _ , err := allEntries .GetCommitsInfo (gocontext .Context (ctx ), commit , treePath )
670
+ if err != nil {
671
+ ctx .ServerError ("GetCommitsInfo" , err )
672
+ return
673
+ }
674
+
659
675
pages := make ([]PageMeta , 0 , len (entries ))
660
676
for _ , entry := range entries {
661
- if ! entry .IsRegular () {
677
+ if ! entry .Entry . IsRegular () {
662
678
continue
663
679
}
664
- c , err := wikiRepo .GetCommitByPath (entry .Name ())
665
- if err != nil {
666
- ctx .ServerError ("GetCommit" , err )
667
- return
668
- }
669
- wikiName , err := wiki_service .GitPathToWebPath (entry .Name ())
680
+ wikiName , err := wiki_service .GitPathToWebPath (entry .Entry .Name ())
670
681
if err != nil {
671
682
if repo_model .IsErrWikiInvalidFileName (err ) {
672
683
continue
@@ -678,8 +689,8 @@ func WikiPages(ctx *context.Context) {
678
689
pages = append (pages , PageMeta {
679
690
Name : displayName ,
680
691
SubURL : wiki_service .WebPathToURLPath (wikiName ),
681
- GitEntryName : entry .Name (),
682
- UpdatedUnix : timeutil .TimeStamp (c .Author .When .Unix ()),
692
+ GitEntryName : entry .Entry . Name (),
693
+ UpdatedUnix : timeutil .TimeStamp (entry . Commit .Author .When .Unix ()),
683
694
})
684
695
}
685
696
ctx .Data ["Pages" ] = pages
0 commit comments