summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2014-03-15 22:27:24 +0800
committerLunny Xiao <xiaolunwen@gmail.com>2014-03-15 22:27:24 +0800
commit218cafed1d2ff1ef04174d433a73cd210925902c (patch)
treef2e49e2bee0e1618b99c3abac1c53786ca9db451 /models
parentf174633b36ef102d8e8324dd708b96335188f5dd (diff)
downloadgitea-218cafed1d2ff1ef04174d433a73cd210925902c.tar.gz
gitea-218cafed1d2ff1ef04174d433a73cd210925902c.zip
show folder first on file list page
Diffstat (limited to 'models')
-rw-r--r--models/repo2.go33
1 files changed, 23 insertions, 10 deletions
diff --git a/models/repo2.go b/models/repo2.go
index 6aa6eda60c..beeb8021ed 100644
--- a/models/repo2.go
+++ b/models/repo2.go
@@ -8,7 +8,7 @@ import (
"path"
"time"
- git "github.com/speedata/gogit"
+ git "github.com/gogits/git"
)
type RepoFile struct {
@@ -46,20 +46,33 @@ 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 {
- repofiles = append(repofiles, &RepoFile{
- entry.Id,
- entry.Filemode,
- entry.Name,
- path.Join(dirname, entry.Name),
- lastCommit.Message(),
- lastCommit.Committer.When,
- })
+ switch entry.Filemode {
+ case git.FileModeBlob, git.FileModeBlobExec:
+ repofiles = append(repofiles, &RepoFile{
+ entry.Id,
+ entry.Filemode,
+ entry.Name,
+ path.Join(dirname, entry.Name),
+ 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
}