Fix bug in repos search (#884)

This commit is contained in:
Ethan Koenig 2017-02-09 20:30:26 -05:00 committed by Lunny Xiao
parent b6dd6210ea
commit 2f13d31ff0

View file

@ -56,18 +56,22 @@ func Search(ctx *context.APIContext) {
} }
results := make([]*api.Repository, len(repos)) results := make([]*api.Repository, len(repos))
for i := range repos { for i, repo := range repos {
if err = repos[i].GetOwner(); err != nil { if err = repo.GetOwner(); err != nil {
ctx.JSON(500, map[string]interface{}{ ctx.JSON(500, map[string]interface{}{
"ok": false, "ok": false,
"error": err.Error(), "error": err.Error(),
}) })
return return
} }
results[i] = &api.Repository{ accessMode, err := models.AccessLevel(ctx.User, repo)
ID: repos[i].ID, if err != nil {
FullName: path.Join(repos[i].Owner.Name, repos[i].Name), ctx.JSON(500, map[string]interface{}{
"ok": false,
"error": err.Error(),
})
} }
results[i] = repo.APIFormat(accessMode)
} }
ctx.SetLinkHeader(int(count), setting.API.MaxResponseItems) ctx.SetLinkHeader(int(count), setting.API.MaxResponseItems)