diff options
author | Unknown <joe2010xtmf@163.com> | 2014-03-15 10:29:22 -0400 |
---|---|---|
committer | Unknown <joe2010xtmf@163.com> | 2014-03-15 10:29:22 -0400 |
commit | c44f18cae13b9833636624c3ac9e5c5d12cf526f (patch) | |
tree | 9ba9319ec79ccbd9d89d85be0d7817a5fc75828c /models/repo2.go | |
parent | b3373aa8d3c7bf0e7aac61fca4a6130d3f12e027 (diff) | |
parent | ca86433402463fb423b75d1527407c5203aba5ce (diff) |
Merge branch 'master' of github.com:gogits/gogs
Diffstat (limited to 'models/repo2.go')
-rw-r--r-- | models/repo2.go | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/models/repo2.go b/models/repo2.go index 6aa6eda6..beeb8021 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 } |