forked from forgejo/forgejo
improve get commits performance
This commit is contained in:
parent
acdb4d8bdd
commit
7509fa2c33
6 changed files with 10 additions and 36 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue