mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-23 07:34:02 +01:00
Fix bug in repos search (#884)
This commit is contained in:
parent
b6dd6210ea
commit
2f13d31ff0
1 changed files with 9 additions and 5 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue