1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-12-21 16:53:08 +00:00

update repo page

This commit is contained in:
Lunny Xiao 2014-03-13 14:50:09 +08:00
parent 18ba149137
commit 3a1fa012f7
3 changed files with 18 additions and 9 deletions

View file

@ -268,13 +268,21 @@ const (
)
type RepoFile struct {
Type int
Name string
Type int
Name string
Message string
Created time.Time
}
func GetReposFiles(userName, reposName, treeName, rpath string) ([]RepoFile, error) {
func (f *RepoFile) IsFile() bool {
return f.Type == git.FilemodeBlob || f.Type == git.FilemodeBlobExecutable
}
func (f *RepoFile) IsDir() bool {
return f.Type == git.FilemodeTree
}
func GetReposFiles(userName, reposName, treeName, rpath string) ([]*RepoFile, error) {
f := RepoPath(userName, reposName)
repo, err := git.OpenRepository(f)
if err != nil {
@ -286,7 +294,7 @@ func GetReposFiles(userName, reposName, treeName, rpath string) ([]RepoFile, err
return nil, err
}
lastCommit := obj.(*git.Commit)
var repofiles []RepoFile
var repofiles []*RepoFile
tree, err := lastCommit.Tree()
if err != nil {
return nil, err
@ -294,10 +302,12 @@ func GetReposFiles(userName, reposName, treeName, rpath string) ([]RepoFile, err
var i uint64 = 0
for ; i < tree.EntryCount(); i++ {
entry := tree.EntryByIndex(i)
repofiles = append(repofiles, RepoFile{
repofiles = append(repofiles, &RepoFile{
entry.Filemode,
entry.Name,
time.Now(),
lastCommit.Message(),
lastCommit.Committer().When,
})
}

View file

@ -23,7 +23,6 @@ func Single(params martini.Params, r render.Render, data base.TmplData) {
}
data["IsRepoToolbarSource"] = true
data["Files"] = files
r.HTML(200, "repo/single", data)

View file

@ -6,7 +6,7 @@
<h4>Source Files:</h4>
<ul>
{{range .Files}}
<li>{{.Name}} - {{.Type}}</li>
<li>{{.Name}} - {{.Message}} - {{.Created}} - {{.IsFile}} - {{.IsDir}}</li>
{{end}}
</ul>
</div>