summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2019-01-02 10:40:33 +0900
committerShinya Maeda <shinya@gitlab.com>2019-01-04 22:17:02 +0900
commit66755c9ed506af9f51022a678ed26e5d31ee87ac (patch)
treeae453c58166702161f7544e74995c43822017deb /lib
parentb4f4edd4eed2e469c2b19a12166232f48eaf2181 (diff)
downloadgitlab-ce-66755c9ed506af9f51022a678ed26e5d31ee87ac.tar.gz
Support CURD operation for release asset links
- Add Releases::Links model - Expose it in release API - Add integration tests
Diffstat (limited to 'lib')
-rw-r--r--lib/api/entities.rb22
-rw-r--r--lib/api/releases.rb11
-rw-r--r--lib/gitlab/import_export/import_export.yml3
-rw-r--r--lib/gitlab/import_export/relation_factory.rb3
4 files changed, 37 insertions, 2 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index 7116ab2882b..97ccd97e883 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -1093,12 +1093,34 @@ module API
expose :description
end
+ module Releases
+ class Link < Grape::Entity
+ expose :id
+ expose :name
+ expose :url
+ expose :external?, as: :external
+ end
+
+ class Source < Grape::Entity
+ expose :format
+ expose :url
+ end
+ end
+
class Release < TagRelease
expose :name
expose :description_html
expose :created_at
expose :author, using: Entities::UserBasic, if: -> (release, _) { release.author.present? }
expose :commit, using: Entities::Commit
+
+ expose :assets do
+ expose :assets_count, as: :count
+ expose :sources, using: Entities::Releases::Source
+ expose :links, using: Entities::Releases::Link do |release, options|
+ release.links.sorted
+ end
+ end
end
class Tag < Grape::Entity
diff --git a/lib/api/releases.rb b/lib/api/releases.rb
index 37d06988e64..63c755f3620 100644
--- a/lib/api/releases.rb
+++ b/lib/api/releases.rb
@@ -49,6 +49,10 @@ module API
requires :name, type: String, desc: 'The name of the release'
requires :description, type: String, desc: 'The release notes'
optional :ref, type: String, desc: 'The commit sha or branch name'
+ optional :links_attributes, type: Array do
+ requires :name, type: String
+ requires :url, type: String
+ end
end
post ':id/releases' do
authorize_create_release!
@@ -72,6 +76,13 @@ module API
requires :tag_name, type: String, desc: 'The name of the tag', as: :tag
optional :name, type: String, desc: 'The name of the release'
optional :description, type: String, desc: 'Release notes with markdown support'
+ optional :links_attributes, type: Array do
+ optional :id, type: Integer
+ optional :name, type: String
+ optional :url, type: String
+ optional :_destroy, type: Integer
+ at_least_one_of :name, :url, :_destroy
+ end
end
put ':id/releases/:tag_name', requirements: RELEASE_ENDPOINT_REQUIREMETS do
authorize_update_release!
diff --git a/lib/gitlab/import_export/import_export.yml b/lib/gitlab/import_export/import_export.yml
index 25cdd5ab121..9fb1ae9f64b 100644
--- a/lib/gitlab/import_export/import_export.yml
+++ b/lib/gitlab/import_export/import_export.yml
@@ -28,7 +28,8 @@ project_tree:
- notes:
:author
- releases:
- :author
+ - :author
+ - :links
- project_members:
- :user
- merge_requests:
diff --git a/lib/gitlab/import_export/relation_factory.rb b/lib/gitlab/import_export/relation_factory.rb
index a4902e2104f..a0f4dcfb772 100644
--- a/lib/gitlab/import_export/relation_factory.rb
+++ b/lib/gitlab/import_export/relation_factory.rb
@@ -23,7 +23,8 @@ module Gitlab
custom_attributes: 'ProjectCustomAttribute',
project_badges: 'Badge',
metrics: 'MergeRequest::Metrics',
- ci_cd_settings: 'ProjectCiCdSetting' }.freeze
+ ci_cd_settings: 'ProjectCiCdSetting',
+ links: 'Releases::Link' }.freeze
USER_REFERENCES = %w[author_id assignee_id updated_by_id merged_by_id latest_closed_by_id user_id created_by_id last_edited_by_id merge_user_id resolved_by_id closed_by_id].freeze