1
0
Fork 0
forked from forgejo/forgejo

API: Return primary language and repository language stats API URL (#18396)

This commit is contained in:
Lauris BH 2022-01-25 08:33:40 +02:00 committed by GitHub
parent 9628a76ce6
commit 6392f4691a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 55 additions and 2 deletions

View file

@ -533,6 +533,11 @@ func Get(ctx *context.APIContext) {
// "200":
// "$ref": "#/responses/Repository"
if err := ctx.Repo.Repository.LoadAttributes(ctx); err != nil {
ctx.Error(http.StatusInternalServerError, "Repository.LoadAttributes", err)
return
}
ctx.JSON(http.StatusOK, convert.ToRepo(ctx.Repo.Repository, ctx.Repo.AccessMode))
}

View file

@ -32,6 +32,11 @@ func listUserRepos(ctx *context.APIContext, u *user_model.User, private bool) {
return
}
if err := repos.LoadAttributes(); err != nil {
ctx.Error(http.StatusInternalServerError, "RepositoryList.LoadAttributes", err)
return
}
apiRepos := make([]*api.Repository, 0, len(repos))
for i := range repos {
access, err := models.AccessLevel(ctx.User, repos[i])