summaryrefslogtreecommitdiff
path: root/lib/api/entities.rb
diff options
context:
space:
mode:
authorDJ Mountney <david@twkie.net>2018-10-29 14:37:19 -0700
committerDJ Mountney <david@twkie.net>2018-10-29 14:37:19 -0700
commit06b6daacb15b92b04e05538b37aadfdb04fc5a4b (patch)
tree0500cf47f7d8d2e6bc7ed53cbf9ad957f07fb31a /lib/api/entities.rb
parentc847f172d25efc211045c363f4e55402ad250c09 (diff)
parent45b61a9ece48550f51432c8cca7de7e1a298ca08 (diff)
downloadgitlab-ce-06b6daacb15b92b04e05538b37aadfdb04fc5a4b.tar.gz
Merge remote-tracking branch 'origin/master' into dev-master
Diffstat (limited to 'lib/api/entities.rb')
-rw-r--r--lib/api/entities.rb23
1 files changed, 20 insertions, 3 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index 18c30723d73..9f7be27b047 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -160,13 +160,27 @@ module API
# (fixed in https://github.com/rails/rails/pull/25976).
project.tags.map(&:name).sort
end
+
expose :ssh_url_to_repo, :http_url_to_repo, :web_url, :readme_url
+
+ expose :license_url, if: :license do |project|
+ license = project.repository.license_blob
+
+ if license
+ Gitlab::Routing.url_helpers.project_blob_url(project, File.join(project.default_branch, license.path))
+ end
+ end
+
+ expose :license, with: 'API::Entities::LicenseBasic', if: :license do |project|
+ project.repository.license
+ end
+
expose :avatar_url do |project, options|
project.avatar_url(only_path: false)
end
+
expose :star_count, :forks_count
expose :last_activity_at
-
expose :namespace, using: 'API::Entities::NamespaceBasic'
expose :custom_attributes, using: 'API::Entities::CustomAttribute', if: :with_custom_attributes
@@ -1208,11 +1222,14 @@ module API
expose :deployable, using: Entities::Job
end
- class License < Grape::Entity
+ class LicenseBasic < Grape::Entity
expose :key, :name, :nickname
- expose :popular?, as: :popular
expose :url, as: :html_url
expose(:source_url) { |license| license.meta['source'] }
+ end
+
+ class License < LicenseBasic
+ expose :popular?, as: :popular
expose(:description) { |license| license.meta['description'] }
expose(:conditions) { |license| license.meta['conditions'] }
expose(:permissions) { |license| license.meta['permissions'] }