Skip to content

Commit 7509fa2

Browse files
committed
improve get commits performance
1 parent acdb4d8 commit 7509fa2

File tree

6 files changed

+10
-36
lines changed

6 files changed

+10
-36
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?bra
33

44
![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true)
55

6-
##### Current version: 0.8.2
6+
##### Current version: 0.8.3
77

88
| Web | UI | Preview |
99
|:-------------:|:-------:|:-------:|

cmd/web.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func checkVersion() {
8888
{"github.com/go-macaron/toolbox", toolbox.Version, "0.1.0"},
8989
{"gopkg.in/ini.v1", ini.Version, "1.8.4"},
9090
{"gopkg.in/macaron.v1", macaron.Version, "0.8.0"},
91-
{"github.com/gogits/git-shell", git.Version, "0.1.1"},
91+
{"github.com/gogits/git-shell", git.Version, "0.2.0"},
9292
}
9393
for _, c := range checkers {
9494
if !version.Compare(c.Version(), c.Expected, ">=") {

gogs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
"github.com/gogits/gogs/modules/setting"
1919
)
2020

21-
const APP_VER = "0.8.2.1213"
21+
const APP_VER = "0.8.3.1213"
2222

2323
func init() {
2424
runtime.GOMAXPROCS(runtime.NumCPU())

routers/repo/view.go

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@ import (
88
"bytes"
99
"io/ioutil"
1010
"path"
11-
"path/filepath"
1211
"strings"
1312

1413
"github.com/Unknwon/paginater"
1514

16-
"github.com/gogits/git-shell"
15+
git "github.com/gogits/git-shell"
1716

1817
"github.com/gogits/gogs/models"
1918
"github.com/gogits/gogs/modules/base"
@@ -134,38 +133,13 @@ func Home(ctx *middleware.Context) {
134133
}
135134
entries.Sort()
136135

137-
files := make([][]interface{}, 0, len(entries))
138-
for _, te := range entries {
139-
if te.Type != git.OBJECT_COMMIT {
140-
c, err := ctx.Repo.Commit.GetCommitByPath(filepath.Join(treePath, te.Name()))
141-
if err != nil {
142-
ctx.Handle(500, "GetCommitByPath", err)
143-
return
144-
}
145-
files = append(files, []interface{}{te, c})
146-
} else {
147-
sm, err := ctx.Repo.Commit.GetSubModule(path.Join(treename, te.Name()))
148-
if err != nil {
149-
ctx.Handle(500, "GetSubModule", err)
150-
return
151-
}
152-
smUrl := ""
153-
if sm != nil {
154-
smUrl = sm.Url
155-
}
156-
157-
c, err := ctx.Repo.Commit.GetCommitByPath(filepath.Join(treePath, te.Name()))
158-
if err != nil {
159-
ctx.Handle(500, "GetCommitByPath", err)
160-
return
161-
}
162-
files = append(files, []interface{}{te, git.NewSubModuleFile(c, smUrl, te.ID.String())})
163-
}
136+
ctx.Data["Files"], err = entries.GetCommitsInfo(ctx.Repo.Commit, treePath)
137+
if err != nil {
138+
ctx.Handle(500, "GetCommitsInfo", err)
139+
return
164140
}
165-
ctx.Data["Files"] = files
166141

167142
var readmeFile *git.Blob
168-
169143
for _, f := range entries {
170144
if f.IsDir() || !base.IsReadmeFile(f.Name()) {
171145
continue

templates/.VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.8.2.1213
1+
0.8.3.1213

templates/repo/header.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<a href="{{AppSubUrl}}/{{.Owner.Name}}">{{.Owner.Name}}</a>
99
<div class="divider"> / </div>
1010
<a href="{{$.RepoLink}}">{{.Name}}</a>
11-
{{if .IsMirror}}<div class="fork-flag">{{$.i18n.Tr "repo.mirror_from"}} <a target="_blank" href="{{$.MirrorAddress}}">{{$.Mirror.Address}}</a></div>{{end}}
11+
{{if .IsMirror}}<div class="fork-flag">{{$.i18n.Tr "repo.mirror_from"}} <a target="_blank" href="{{$.Mirror.Address}}">{{$.Mirror.Address}}</a></div>{{end}}
1212
{{if .IsFork}}<div class="fork-flag">{{$.i18n.Tr "repo.forked_from"}} <a href="{{.BaseRepo.RepoLink}}">{{SubStr .BaseRepo.RepoLink 1 -1}}</a></div>{{end}}
1313
</div>
1414

0 commit comments

Comments
 (0)