show readme.md

This commit is contained in:
slene 2014-03-17 18:46:54 +08:00
parent 26f9962b6e
commit 5bc2a1a6f9
4 changed files with 101 additions and 17 deletions

View file

@ -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,
})
}
}