]> source.dussan.org Git - gitea.git/commitdiff
bug fixed for commits list
authorLunny Xiao <xiaolunwen@gmail.com>
Wed, 19 Mar 2014 06:39:07 +0000 (14:39 +0800)
committerLunny Xiao <xiaolunwen@gmail.com>
Wed, 19 Mar 2014 06:39:07 +0000 (14:39 +0800)
models/repo.go
modules/base/template.go
templates/repo/commits.tmpl
web.go

index c37fb4de20bac09d3e547d0a2540966448f8d5a1..1331bbf45035a3d28372f5a2aad0a8f4b0f82810 100644 (file)
@@ -5,6 +5,7 @@
 package models
 
 import (
+       "container/list"
        "errors"
        "fmt"
        "io/ioutil"
@@ -601,7 +602,7 @@ func GetLastestCommit(userName, repoName string) (*Commit, error) {
 }*/
 
 // GetCommits returns all commits of given branch of repository.
-func GetCommits(userName, reposName, branchname string) ([]*git.Commit, error) {
+func GetCommits(userName, reposName, branchname string) (*list.List, error) {
        repo, err := git.OpenRepository(RepoPath(userName, reposName))
        if err != nil {
                return nil, err
index 4517cd47aad400595b5bb9d4205d08f256923b3d..db79340e750475ddaa02c0ee4a13a324a082b68d 100644 (file)
@@ -5,6 +5,7 @@
 package base
 
 import (
+       "container/list"
        "html/template"
 )
 
@@ -12,6 +13,23 @@ func Str2html(raw string) template.HTML {
        return template.HTML(raw)
 }
 
+func Range(l int) []int {
+       return make([]int, l)
+}
+
+func List(l *list.List) chan interface{} {
+       e := l.Front()
+       c := make(chan interface{})
+       go func() {
+               for e != nil {
+                       c <- e.Value
+                       e = e.Next()
+               }
+               close(c)
+       }()
+       return c
+}
+
 var TemplateFuncs template.FuncMap = map[string]interface{}{
        "AppName": func() string {
                return AppName
@@ -30,4 +48,5 @@ var TemplateFuncs template.FuncMap = map[string]interface{}{
        "ActionIcon": ActionIcon,
        "ActionDesc": ActionDesc,
        "DateFormat": DateFormat,
+       "List":       List,
 }
index 9190a030a34066107ecb665c9fc70fb54b884c93..4bffb9daf7fd42d2f15977b0dd9b82be0c8a5e66 100644 (file)
@@ -5,8 +5,9 @@
 <div id="gogs-body" class="container">
     <div id="gogs-commits">
     <ul>
-    {{range .Commits}}
-    <li>{{.Committer.Name}} - {{.Id}} - {{.Message}} - {{.Committer.When}}</li>
+    {{$r := List .Commits}}
+    {{range $r}}
+                   <li>{{.Committer.Name}} - {{.Id}} - {{.Message}} - {{.Committer.When}}</li>
     {{end}}
     </ul>
     </div>
diff --git a/web.go b/web.go
index ca504ea56013d72959fc2af9db2480c2aefa2eab..3ca93f307d66eb2f8c5c6372a3ee68b06a7ec4d7 100644 (file)
--- a/web.go
+++ b/web.go
@@ -34,6 +34,10 @@ gogs web`,
        Flags:  []cli.Flag{},
 }
 
+func Range(l int) []int {
+       return make([]int, l)
+}
+
 func runWeb(*cli.Context) {
        log.Info("%s %s", base.AppName, base.AppVer)