1
0
Fork 0
forked from forgejo/forgejo

improve get commits performance

This commit is contained in:
Unknwon 2015-12-13 22:58:12 -05:00
parent acdb4d8bdd
commit 7509fa2c33
6 changed files with 10 additions and 36 deletions

View file

@ -8,12 +8,11 @@ import (
"bytes"
"io/ioutil"
"path"
"path/filepath"
"strings"
"github.com/Unknwon/paginater"
"github.com/gogits/git-shell"
git "github.com/gogits/git-shell"
"github.com/gogits/gogs/models"
"github.com/gogits/gogs/modules/base"
@ -134,38 +133,13 @@ func Home(ctx *middleware.Context) {
}
entries.Sort()
files := make([][]interface{}, 0, len(entries))
for _, te := range entries {
if te.Type != git.OBJECT_COMMIT {
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, 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"], err = entries.GetCommitsInfo(ctx.Repo.Commit, treePath)
if err != nil {
ctx.Handle(500, "GetCommitsInfo", err)
return
}
ctx.Data["Files"] = files
var readmeFile *git.Blob
for _, f := range entries {
if f.IsDir() || !base.IsReadmeFile(f.Name()) {
continue