This commit is contained in:
yystopf 2022-07-26 09:39:15 +08:00
parent 677f1872f6
commit f433cede0a
1 changed files with 14 additions and 4 deletions

View File

@ -326,7 +326,12 @@ func ListWikiPages(ctx *context.APIContext) {
continue
}
if entry.IsRegular() {
c, err := wikiRepo.GetCommitByPath(fmt.Sprintf("%s/%s", filePath, entry.Name()))
var commit *git.Commit
if filePath == "" {
commit, err = wikiRepo.GetCommitByPath(entry.Name())
} else {
commit, err = wikiRepo.GetCommitByPath(fmt.Sprintf("%s/%s", filePath, entry.Name()))
}
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetCommit", err)
return
@ -339,15 +344,20 @@ func ListWikiPages(ctx *context.APIContext) {
ctx.Error(http.StatusInternalServerError, "WikiFilenameToName", err)
return
}
lists = append(lists, convert.RegularToWikiPageMetaData(wikiName, c, ctx.Repo.Repository))
lists = append(lists, convert.RegularToWikiPageMetaData(wikiName, commit, ctx.Repo.Repository))
}
if entry.IsDir() {
c, err := wikiRepo.GetCommitByPath(fmt.Sprintf("%s/%s", filePath, entry.Name()))
var commit *git.Commit
if filePath == "" {
commit, err = wikiRepo.GetCommitByPath(entry.Name())
} else {
commit, err = wikiRepo.GetCommitByPath(fmt.Sprintf("%s/%s", filePath, entry.Name()))
}
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetCommit", err)
return
}
lists = append(lists, convert.DirToWikiPageMetaData(entry.Name(), c, ctx.Repo.Repository))
lists = append(lists, convert.DirToWikiPageMetaData(entry.Name(), commit, ctx.Repo.Repository))
}
}