diff options
author | Unknwon <u@gogs.io> | 2015-12-13 22:58:12 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-12-13 22:58:12 -0500 |
commit | 7509fa2c33b6eeff20091a4c6883c006d99b3425 (patch) | |
tree | 91f436036cb421eed20e7e6caca5bd96150866f7 /routers/repo | |
parent | acdb4d8bdd31ee910c6c5fa6db65379703bdfbca (diff) | |
download | gitea-7509fa2c33b6eeff20091a4c6883c006d99b3425.tar.gz gitea-7509fa2c33b6eeff20091a4c6883c006d99b3425.zip |
improve get commits performance
Diffstat (limited to 'routers/repo')
-rw-r--r-- | routers/repo/view.go | 36 |
1 files changed, 5 insertions, 31 deletions
diff --git a/routers/repo/view.go b/routers/repo/view.go index f019256d3e..e4815bf0c5 100644 --- a/routers/repo/view.go +++ b/routers/repo/view.go @@ -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 |