mirror of
https://github.com/go-gitea/gitea.git
synced 2024-11-23 08:26:35 +08:00
show folder first on file list page
This commit is contained in:
parent
f174633b36
commit
218cafed1d
|
@ -8,7 +8,7 @@ import (
|
|||
"path"
|
||||
"time"
|
||||
|
||||
git "github.com/speedata/gogit"
|
||||
git "github.com/gogits/git"
|
||||
)
|
||||
|
||||
type RepoFile struct {
|
||||
|
@ -46,9 +46,12 @@ func GetReposFiles(userName, reposName, branchName, rpath string) ([]*RepoFile,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
var repodirs []*RepoFile
|
||||
var repofiles []*RepoFile
|
||||
lastCommit.Tree.Walk(func(dirname string, entry *git.TreeEntry) int {
|
||||
if dirname == rpath {
|
||||
switch entry.Filemode {
|
||||
case git.FileModeBlob, git.FileModeBlobExec:
|
||||
repofiles = append(repofiles, &RepoFile{
|
||||
entry.Id,
|
||||
entry.Filemode,
|
||||
|
@ -57,9 +60,19 @@ func GetReposFiles(userName, reposName, branchName, rpath string) ([]*RepoFile,
|
|||
lastCommit.Message(),
|
||||
lastCommit.Committer.When,
|
||||
})
|
||||
case git.FileModeTree:
|
||||
repodirs = append(repodirs, &RepoFile{
|
||||
entry.Id,
|
||||
entry.Filemode,
|
||||
entry.Name,
|
||||
path.Join(dirname, entry.Name),
|
||||
lastCommit.Message(),
|
||||
lastCommit.Committer.When,
|
||||
})
|
||||
}
|
||||
}
|
||||
return 0
|
||||
})
|
||||
|
||||
return repofiles, nil
|
||||
return append(repodirs, repofiles...), nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user