mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	bug fixed for commits list
This commit is contained in:
		@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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,
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -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>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user