From 7509fa2c33b6eeff20091a4c6883c006d99b3425 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Sun, 13 Dec 2015 22:58:12 -0500 Subject: [PATCH] improve get commits performance --- README.md | 2 +- cmd/web.go | 2 +- gogs.go | 2 +- routers/repo/view.go | 36 +++++------------------------------- templates/.VERSION | 2 +- templates/repo/header.tmpl | 2 +- 6 files changed, 10 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index ca82dc7a3c..1a26ed0f94 100644 --- a/README.md +++ b/README.md @@ -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) -##### Current version: 0.8.2 +##### Current version: 0.8.3 | Web | UI | Preview | |:-------------:|:-------:|:-------:| diff --git a/cmd/web.go b/cmd/web.go index 107250844a..aec091e453 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -88,7 +88,7 @@ func checkVersion() { {"github.com/go-macaron/toolbox", toolbox.Version, "0.1.0"}, {"gopkg.in/ini.v1", ini.Version, "1.8.4"}, {"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 { if !version.Compare(c.Version(), c.Expected, ">=") { diff --git a/gogs.go b/gogs.go index 1aba36339d..e56fbf414e 100644 --- a/gogs.go +++ b/gogs.go @@ -18,7 +18,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.8.2.1213" +const APP_VER = "0.8.3.1213" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) 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 diff --git a/templates/.VERSION b/templates/.VERSION index 999b994412..d03366c022 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.8.2.1213 \ No newline at end of file +0.8.3.1213 \ No newline at end of file diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl index ead981346b..3a1f9cc16b 100644 --- a/templates/repo/header.tmpl +++ b/templates/repo/header.tmpl @@ -8,7 +8,7 @@ {{.Owner.Name}}
/
{{.Name}} - {{if .IsMirror}}
{{$.i18n.Tr "repo.mirror_from"}} {{$.Mirror.Address}}
{{end}} + {{if .IsMirror}}
{{$.i18n.Tr "repo.mirror_from"}} {{$.Mirror.Address}}
{{end}} {{if .IsFork}}
{{$.i18n.Tr "repo.forked_from"}} {{SubStr .BaseRepo.RepoLink 1 -1}}
{{end}}