diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-11-28 13:14:04 +0100 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-11-28 13:14:04 +0100 |
commit | 0b8a2779e788bd05180176a11ac585fd7999b76b (patch) | |
tree | 9426c5fe4eb41513af5066889891c10187da6f9b /lib/api | |
parent | 4c7665f2f930bba855646143684070544044de10 (diff) | |
parent | 0f800a5c0532508c84cee24bf44a4b9ce68168a2 (diff) | |
download | gitlab-ce-0b8a2779e788bd05180176a11ac585fd7999b76b.tar.gz |
Merge branch 'master' into fix/gb/encrypt-runners-tokens
* master: (243 commits)
Conflicts:
db/schema.rb
lib/gitlab/import_export/import_export.yml
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/api.rb | 4 | ||||
-rw-r--r-- | lib/api/entities.rb | 12 | ||||
-rw-r--r-- | lib/api/groups.rb | 14 | ||||
-rw-r--r-- | lib/api/helpers.rb | 1 | ||||
-rw-r--r-- | lib/api/snippets.rb | 1 |
5 files changed, 28 insertions, 4 deletions
diff --git a/lib/api/api.rb b/lib/api/api.rb index 8e259961828..449faf5f8da 100644 --- a/lib/api/api.rb +++ b/lib/api/api.rb @@ -50,6 +50,10 @@ module API rack_response({ 'message' => '404 Not found' }.to_json, 404) end + rescue_from ::Gitlab::ExclusiveLeaseHelpers::FailedToObtainLockError do + rack_response({ 'message' => '409 Conflict: Resource lock' }.to_json, 409) + end + rescue_from UploadedFile::InvalidPathError do |e| rack_response({ 'message' => e.message }.to_json, 400) end diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 5572e86985c..4788b0e16a1 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -145,7 +145,9 @@ module API expose :import_status # TODO: Use `expose_nil` once we upgrade the grape-entity gem - expose :import_error, if: lambda { |status, _ops| status.import_error } + expose :import_error, if: lambda { |project, _ops| project.import_state&.last_error } do |project| + project.import_state.last_error + end end class BasicProjectDetails < ProjectIdentity @@ -248,7 +250,10 @@ module API expose :creator_id expose :forked_from_project, using: Entities::BasicProjectDetails, if: lambda { |project, options| project.forked? } expose :import_status - expose :import_error, if: lambda { |_project, options| options[:user_can_admin_project] } + + expose :import_error, if: lambda { |_project, options| options[:user_can_admin_project] } do |project| + project.import_state&.last_error + end expose :open_issues_count, if: lambda { |project, options| project.feature_available?(:issues, options[:current_user]) } expose :runners_token, if: lambda { |_project, options| options[:user_can_admin_project] } @@ -1142,7 +1147,8 @@ module API end class JobArtifactFile < Grape::Entity - expose :filename, :size + expose :filename + expose :cached_size, as: :size end class JobArtifact < Grape::Entity diff --git a/lib/api/groups.rb b/lib/api/groups.rb index 64b998ab455..b3d10721692 100644 --- a/lib/api/groups.rb +++ b/lib/api/groups.rb @@ -60,7 +60,17 @@ module API def find_group_projects(params) group = find_group!(params[:id]) - projects = GroupProjectsFinder.new(group: group, current_user: current_user, params: project_finder_params).execute + options = { + only_owned: !params[:with_shared], + include_subgroups: params[:include_subgroups] + } + + projects = GroupProjectsFinder.new( + group: group, + current_user: current_user, + params: project_finder_params, + options: options + ).execute projects = projects.with_issues_available_for_user(current_user) if params[:with_issues_enabled] projects = projects.with_merge_requests_enabled if params[:with_merge_requests_enabled] projects = reorder_projects(projects) @@ -201,6 +211,8 @@ module API optional :starred, type: Boolean, default: false, desc: 'Limit by starred status' optional :with_issues_enabled, type: Boolean, default: false, desc: 'Limit by enabled issues feature' optional :with_merge_requests_enabled, type: Boolean, default: false, desc: 'Limit by enabled merge requests feature' + optional :with_shared, type: Boolean, default: true, desc: 'Include projects shared to this group' + optional :include_subgroups, type: Boolean, default: false, desc: 'Includes projects in subgroups of this group' use :pagination use :with_custom_attributes diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index 60bf977f0e4..9fda73d5b92 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -494,6 +494,7 @@ module API def send_git_blob(repository, blob) env['api.format'] = :txt content_type 'text/plain' + header['Content-Disposition'] = "attachment; filename=#{blob.name.inspect}" header(*Gitlab::Workhorse.send_git_blob(repository, blob)) end diff --git a/lib/api/snippets.rb b/lib/api/snippets.rb index 1ae144ca9c1..326d55afd0e 100644 --- a/lib/api/snippets.rb +++ b/lib/api/snippets.rb @@ -146,6 +146,7 @@ module API env['api.format'] = :txt content_type 'text/plain' + header['Content-Disposition'] = 'attachment' present snippet.content end # rubocop: enable CodeReuse/ActiveRecord |