summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEthan Koenig <etk39@cornell.edu>2017-02-09 20:30:26 -0500
committerLunny Xiao <xiaolunwen@gmail.com>2017-02-10 09:30:26 +0800
commit2f13d31ff07ca7993b8451446eb756d0521ec897 (patch)
tree6304a90328ebe8aab463ba5ed99910291726adfd
parentb6dd6210eaebc915fd5be5579c58cce4da2e2579 (diff)
downloadgitea-2f13d31ff07ca7993b8451446eb756d0521ec897.tar.gz
gitea-2f13d31ff07ca7993b8451446eb756d0521ec897.zip
Fix bug in repos search (#884)
-rw-r--r--routers/api/v1/repo/repo.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go
index d65f30d729..02c017243e 100644
--- a/routers/api/v1/repo/repo.go
+++ b/routers/api/v1/repo/repo.go
@@ -56,18 +56,22 @@ func Search(ctx *context.APIContext) {
}
results := make([]*api.Repository, len(repos))
- for i := range repos {
- if err = repos[i].GetOwner(); err != nil {
+ for i, repo := range repos {
+ if err = repo.GetOwner(); err != nil {
ctx.JSON(500, map[string]interface{}{
"ok": false,
"error": err.Error(),
})
return
}
- results[i] = &api.Repository{
- ID: repos[i].ID,
- FullName: path.Join(repos[i].Owner.Name, repos[i].Name),
+ accessMode, err := models.AccessLevel(ctx.User, repo)
+ if err != nil {
+ ctx.JSON(500, map[string]interface{}{
+ "ok": false,
+ "error": err.Error(),
+ })
}
+ results[i] = repo.APIFormat(accessMode)
}
ctx.SetLinkHeader(int(count), setting.API.MaxResponseItems)