summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorslene <vslene@gmail.com>2014-03-17 18:46:54 +0800
committerslene <vslene@gmail.com>2014-03-17 18:46:54 +0800
commit5bc2a1a6f98ae42ab5c30299d26082ffae54b859 (patch)
tree5bed6b099888bf745a9f749e90de22d61ee14618 /models
parent26f9962b6e0089773615ca34ab80ca01ede79790 (diff)
downloadgitea-5bc2a1a6f98ae42ab5c30299d26082ffae54b859.tar.gz
gitea-5bc2a1a6f98ae42ab5c30299d26082ffae54b859.zip
show readme.md
Diffstat (limited to 'models')
-rw-r--r--models/repo2.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/models/repo2.go b/models/repo2.go
index 0c17a58335..b31244b414 100644
--- a/models/repo2.go
+++ b/models/repo2.go
@@ -5,6 +5,7 @@
package models
import (
+ "fmt"
"path"
"strings"
"time"
@@ -22,12 +23,25 @@ type Commit struct {
Message string
}
+var (
+ ErrRepoFileNotLoaded = fmt.Errorf("repo file not loaded")
+)
+
type RepoFile struct {
*git.TreeEntry
Path string
Message string
Created time.Time
Size int64
+ Repo *git.Repository
+}
+
+func (file *RepoFile) LookupBlob() (*git.Blob, error) {
+ if file.Repo == nil {
+ return nil, ErrRepoFileNotLoaded
+ }
+
+ return file.Repo.LookupBlob(file.Id)
}
func GetBranches(userName, reposName string) ([]string, error) {
@@ -80,6 +94,7 @@ func GetReposFiles(userName, reposName, branchName, rpath string) ([]*RepoFile,
lastCommit.Message(),
lastCommit.Committer.When,
size,
+ repo,
})
case git.FileModeTree:
repodirs = append(repodirs, &RepoFile{
@@ -88,6 +103,7 @@ func GetReposFiles(userName, reposName, branchName, rpath string) ([]*RepoFile,
lastCommit.Message(),
lastCommit.Committer.When,
size,
+ repo,
})
}
}