diff options
author | Lauris BH <lauris@nix.lv> | 2022-01-25 08:33:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-25 08:33:40 +0200 |
commit | 6392f4691af7db20a2ad81ec19408fa9377a5cd1 (patch) | |
tree | 0553b384cdde77323b40f8d70daa38ba8d4a5280 /modules | |
parent | 9628a76ce6f4fea8508f79747d78007907e3ea76 (diff) | |
download | gitea-6392f4691af7db20a2ad81ec19408fa9377a5cd1.tar.gz gitea-6392f4691af7db20a2ad81ec19408fa9377a5cd1.zip |
API: Return primary language and repository language stats API URL (#18396)
Diffstat (limited to 'modules')
-rw-r--r-- | modules/convert/repository.go | 9 | ||||
-rw-r--r-- | modules/structs/repo.go | 2 |
2 files changed, 11 insertions, 0 deletions
diff --git a/modules/convert/repository.go b/modules/convert/repository.go index a356925539..1f11fda7ac 100644 --- a/modules/convert/repository.go +++ b/modules/convert/repository.go @@ -125,6 +125,13 @@ func innerToRepo(repo *repo_model.Repository, mode perm.AccessMode, isParent boo } } + var language string + if repo.PrimaryLanguage != nil { + language = repo.PrimaryLanguage.Language + } + + repoAPIURL := repo.APIURL() + return &api.Repository{ ID: repo.ID, Owner: ToUserWithAccessMode(repo.Owner, mode), @@ -144,6 +151,8 @@ func innerToRepo(repo *repo_model.Repository, mode perm.AccessMode, isParent boo CloneURL: cloneLink.HTTPS, OriginalURL: repo.SanitizedOriginalURL(), Website: repo.Website, + Language: language, + LanguagesURL: repoAPIURL + "/languages", Stars: repo.NumStars, Forks: repo.NumForks, Watchers: repo.NumWatches, diff --git a/modules/structs/repo.go b/modules/structs/repo.go index 671885f20a..5a1e99e36b 100644 --- a/modules/structs/repo.go +++ b/modules/structs/repo.go @@ -59,6 +59,8 @@ type Repository struct { Parent *Repository `json:"parent"` Mirror bool `json:"mirror"` Size int `json:"size"` + Language string `json:"language"` + LanguagesURL string `json:"languages_url"` HTMLURL string `json:"html_url"` SSHURL string `json:"ssh_url"` CloneURL string `json:"clone_url"` |