summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2014-03-15 22:43:55 +0800
committerLunny Xiao <xiaolunwen@gmail.com>2014-03-15 22:43:55 +0800
commitaa8b38fe3544b77dd601997179fa51e10117613c (patch)
treed81da3b81f380cca6cb85875fb0fff7f9649e1cf /models
parentca86433402463fb423b75d1527407c5203aba5ce (diff)
downloadgitea-aa8b38fe3544b77dd601997179fa51e10117613c.tar.gz
gitea-aa8b38fe3544b77dd601997179fa51e10117613c.zip
refactoring for Repofile
Diffstat (limited to 'models')
-rw-r--r--models/repo2.go20
1 files changed, 3 insertions, 17 deletions
diff --git a/models/repo2.go b/models/repo2.go
index beeb8021ed..d879130ace 100644
--- a/models/repo2.go
+++ b/models/repo2.go
@@ -12,22 +12,12 @@ import (
)
type RepoFile struct {
- Id *git.Oid
- Type int
- Name string
+ *git.TreeEntry
Path string
Message string
Created time.Time
}
-func (f *RepoFile) IsFile() bool {
- return f.Type == git.FileModeBlob || f.Type == git.FileModeBlobExec
-}
-
-func (f *RepoFile) IsDir() bool {
- return f.Type == git.FileModeTree
-}
-
func GetReposFiles(userName, reposName, branchName, rpath string) ([]*RepoFile, error) {
f := RepoPath(userName, reposName)
@@ -53,18 +43,14 @@ func GetReposFiles(userName, reposName, branchName, rpath string) ([]*RepoFile,
switch entry.Filemode {
case git.FileModeBlob, git.FileModeBlobExec:
repofiles = append(repofiles, &RepoFile{
- entry.Id,
- entry.Filemode,
- entry.Name,
+ entry,
path.Join(dirname, entry.Name),
lastCommit.Message(),
lastCommit.Committer.When,
})
case git.FileModeTree:
repodirs = append(repodirs, &RepoFile{
- entry.Id,
- entry.Filemode,
- entry.Name,
+ entry,
path.Join(dirname, entry.Name),
lastCommit.Message(),
lastCommit.Committer.When,