]> source.dussan.org Git - gitea.git/commitdiff
refactoring for Repofile
authorLunny Xiao <xiaolunwen@gmail.com>
Sat, 15 Mar 2014 14:43:55 +0000 (22:43 +0800)
committerLunny Xiao <xiaolunwen@gmail.com>
Sat, 15 Mar 2014 14:43:55 +0000 (22:43 +0800)
models/repo2.go

index beeb8021ed521cea0009b1ec3f61890e8ce7be8d..d879130acef0664421eacf364665f74b7786e2cd 100644 (file)
@@ -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,