mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-18 06:58:19 +00:00
improve get commits performance
This commit is contained in:
parent
acdb4d8bdd
commit
7509fa2c33
|
@ -3,7 +3,7 @@ Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?bra
|
||||||
|
|
||||||
![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true)
|
![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true)
|
||||||
|
|
||||||
##### Current version: 0.8.2
|
##### Current version: 0.8.3
|
||||||
|
|
||||||
| Web | UI | Preview |
|
| Web | UI | Preview |
|
||||||
|:-------------:|:-------:|:-------:|
|
|:-------------:|:-------:|:-------:|
|
||||||
|
|
|
@ -88,7 +88,7 @@ func checkVersion() {
|
||||||
{"github.com/go-macaron/toolbox", toolbox.Version, "0.1.0"},
|
{"github.com/go-macaron/toolbox", toolbox.Version, "0.1.0"},
|
||||||
{"gopkg.in/ini.v1", ini.Version, "1.8.4"},
|
{"gopkg.in/ini.v1", ini.Version, "1.8.4"},
|
||||||
{"gopkg.in/macaron.v1", macaron.Version, "0.8.0"},
|
{"gopkg.in/macaron.v1", macaron.Version, "0.8.0"},
|
||||||
{"github.com/gogits/git-shell", git.Version, "0.1.1"},
|
{"github.com/gogits/git-shell", git.Version, "0.2.0"},
|
||||||
}
|
}
|
||||||
for _, c := range checkers {
|
for _, c := range checkers {
|
||||||
if !version.Compare(c.Version(), c.Expected, ">=") {
|
if !version.Compare(c.Version(), c.Expected, ">=") {
|
||||||
|
|
2
gogs.go
2
gogs.go
|
@ -18,7 +18,7 @@ import (
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
const APP_VER = "0.8.2.1213"
|
const APP_VER = "0.8.3.1213"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||||
|
|
|
@ -8,12 +8,11 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/Unknwon/paginater"
|
"github.com/Unknwon/paginater"
|
||||||
|
|
||||||
"github.com/gogits/git-shell"
|
git "github.com/gogits/git-shell"
|
||||||
|
|
||||||
"github.com/gogits/gogs/models"
|
"github.com/gogits/gogs/models"
|
||||||
"github.com/gogits/gogs/modules/base"
|
"github.com/gogits/gogs/modules/base"
|
||||||
|
@ -134,38 +133,13 @@ func Home(ctx *middleware.Context) {
|
||||||
}
|
}
|
||||||
entries.Sort()
|
entries.Sort()
|
||||||
|
|
||||||
files := make([][]interface{}, 0, len(entries))
|
ctx.Data["Files"], err = entries.GetCommitsInfo(ctx.Repo.Commit, treePath)
|
||||||
for _, te := range entries {
|
if err != nil {
|
||||||
if te.Type != git.OBJECT_COMMIT {
|
ctx.Handle(500, "GetCommitsInfo", err)
|
||||||
c, err := ctx.Repo.Commit.GetCommitByPath(filepath.Join(treePath, te.Name()))
|
return
|
||||||
if err != nil {
|
|
||||||
ctx.Handle(500, "GetCommitByPath", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
files = append(files, []interface{}{te, c})
|
|
||||||
} else {
|
|
||||||
sm, err := ctx.Repo.Commit.GetSubModule(path.Join(treename, te.Name()))
|
|
||||||
if err != nil {
|
|
||||||
ctx.Handle(500, "GetSubModule", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
smUrl := ""
|
|
||||||
if sm != nil {
|
|
||||||
smUrl = sm.Url
|
|
||||||
}
|
|
||||||
|
|
||||||
c, err := ctx.Repo.Commit.GetCommitByPath(filepath.Join(treePath, te.Name()))
|
|
||||||
if err != nil {
|
|
||||||
ctx.Handle(500, "GetCommitByPath", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
files = append(files, []interface{}{te, git.NewSubModuleFile(c, smUrl, te.ID.String())})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ctx.Data["Files"] = files
|
|
||||||
|
|
||||||
var readmeFile *git.Blob
|
var readmeFile *git.Blob
|
||||||
|
|
||||||
for _, f := range entries {
|
for _, f := range entries {
|
||||||
if f.IsDir() || !base.IsReadmeFile(f.Name()) {
|
if f.IsDir() || !base.IsReadmeFile(f.Name()) {
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
0.8.2.1213
|
0.8.3.1213
|
|
@ -8,7 +8,7 @@
|
||||||
<a href="{{AppSubUrl}}/{{.Owner.Name}}">{{.Owner.Name}}</a>
|
<a href="{{AppSubUrl}}/{{.Owner.Name}}">{{.Owner.Name}}</a>
|
||||||
<div class="divider"> / </div>
|
<div class="divider"> / </div>
|
||||||
<a href="{{$.RepoLink}}">{{.Name}}</a>
|
<a href="{{$.RepoLink}}">{{.Name}}</a>
|
||||||
{{if .IsMirror}}<div class="fork-flag">{{$.i18n.Tr "repo.mirror_from"}} <a target="_blank" href="{{$.MirrorAddress}}">{{$.Mirror.Address}}</a></div>{{end}}
|
{{if .IsMirror}}<div class="fork-flag">{{$.i18n.Tr "repo.mirror_from"}} <a target="_blank" href="{{$.Mirror.Address}}">{{$.Mirror.Address}}</a></div>{{end}}
|
||||||
{{if .IsFork}}<div class="fork-flag">{{$.i18n.Tr "repo.forked_from"}} <a href="{{.BaseRepo.RepoLink}}">{{SubStr .BaseRepo.RepoLink 1 -1}}</a></div>{{end}}
|
{{if .IsFork}}<div class="fork-flag">{{$.i18n.Tr "repo.forked_from"}} <a href="{{.BaseRepo.RepoLink}}">{{SubStr .BaseRepo.RepoLink 1 -1}}</a></div>{{end}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue