diff options
author | Unknwon <u@gogs.io> | 2015-11-13 17:37:02 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-11-13 17:37:02 -0500 |
commit | f8ae161c743f3249e4b580cddc46da41b98652a9 (patch) | |
tree | 1bb44bd477ab0a23313c68bd1309b2a68bfffd67 /routers | |
parent | 1d57f0d64fcd9aec16b4003d5664f31ea748da03 (diff) | |
download | gitea-f8ae161c743f3249e4b580cddc46da41b98652a9.tar.gz gitea-f8ae161c743f3249e4b580cddc46da41b98652a9.zip |
fix #1302
Diffstat (limited to 'routers')
-rw-r--r-- | routers/api/v1/repo.go | 4 | ||||
-rw-r--r-- | routers/user/home.go | 20 |
2 files changed, 11 insertions, 13 deletions
diff --git a/routers/api/v1/repo.go b/routers/api/v1/repo.go index 2341e28878..b4da4c6ff4 100644 --- a/routers/api/v1/repo.go +++ b/routers/api/v1/repo.go @@ -106,9 +106,9 @@ func ListMyRepos(ctx *middleware.Context) { } numOwnRepos := len(ownRepos) - accessibleRepos, err := ctx.User.GetAccessibleRepositories() + accessibleRepos, err := ctx.User.GetRepositoryAccesses() if err != nil { - ctx.APIError(500, "GetAccessibleRepositories", err) + ctx.APIError(500, "GetRepositoryAccesses", err) return } diff --git a/routers/user/home.go b/routers/user/home.go index fc94dfc9e2..b98d7e1157 100644 --- a/routers/user/home.go +++ b/routers/user/home.go @@ -62,23 +62,21 @@ func Dashboard(ctx *middleware.Context) { return } - // Check context type. if !ctxUser.IsOrganization() { - // Normal user. - ctxUser = ctx.User - collaborates, err := ctx.User.GetAccessibleRepositories() + collaborateRepos, err := ctx.User.GetAccessibleRepositories() if err != nil { ctx.Handle(500, "GetAccessibleRepositories", err) return } - repositories := make([]*models.Repository, 0, len(collaborates)) - for repo := range collaborates { - repositories = append(repositories, repo) + for i := range collaborateRepos { + if err = collaborateRepos[i].GetOwner(); err != nil { + ctx.Handle(500, "GetOwner: "+collaborateRepos[i].Name, err) + return + } } - - ctx.Data["CollaborateCount"] = len(repositories) - ctx.Data["CollaborativeRepos"] = repositories + ctx.Data["CollaborateCount"] = len(collaborateRepos) + ctx.Data["CollaborativeRepos"] = collaborateRepos } repos, err := models.GetRepositories(ctxUser.Id, true) @@ -89,7 +87,7 @@ func Dashboard(ctx *middleware.Context) { ctx.Data["Repos"] = repos // Get mirror repositories. - mirrors := make([]*models.Repository, 0, len(repos)/2) + mirrors := make([]*models.Repository, 0, 5) for _, repo := range repos { if repo.IsMirror { if err = repo.GetMirror(); err != nil { |