From 2ec2a906b552d5f4a486130b88a39a4a14e7b28f Mon Sep 17 00:00:00 2001 From: Heinrich Lee Yu Date: Fri, 26 Oct 2018 14:02:20 +0800 Subject: Add group projects API options for including shared and subgroups --- lib/api/groups.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'lib/api') diff --git a/lib/api/groups.rb b/lib/api/groups.rb index 64b998ab455..12227c886b2 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[:include_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 :include_subgroups, type: Boolean, default: false, desc: 'Includes projects in subgroups of this group' + optional :include_shared, type: Boolean, default: true, desc: 'Include projects shared to this group' use :pagination use :with_custom_attributes -- cgit v1.2.1 From b12456049e4e701b2436beacfc88c74922d7524f Mon Sep 17 00:00:00 2001 From: Heinrich Lee Yu Date: Fri, 26 Oct 2018 14:34:31 +0800 Subject: Change param name for consistency --- lib/api/groups.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/api') diff --git a/lib/api/groups.rb b/lib/api/groups.rb index 12227c886b2..b3d10721692 100644 --- a/lib/api/groups.rb +++ b/lib/api/groups.rb @@ -61,7 +61,7 @@ module API def find_group_projects(params) group = find_group!(params[:id]) options = { - only_owned: !params[:include_shared], + only_owned: !params[:with_shared], include_subgroups: params[:include_subgroups] } @@ -211,8 +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' - optional :include_shared, type: Boolean, default: true, desc: 'Include projects shared to this group' use :pagination use :with_custom_attributes -- cgit v1.2.1 From c742d3ba98c7454060068b543cfc1fca926d9be5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= Date: Tue, 20 Nov 2018 11:05:15 +0100 Subject: Use cached size when passing artifacts to Runner --- lib/api/entities.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/api') diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 5572e86985c..cff05643f3b 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -1142,7 +1142,8 @@ module API end class JobArtifactFile < Grape::Entity - expose :filename, :size + expose :filename + expose :cached_size, as: :size end class JobArtifact < Grape::Entity -- cgit v1.2.1 From 9a5703ec82d394c2549f5afda7280c889d4cc373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Javier=20L=C3=B3pez?= Date: Fri, 23 Nov 2018 16:44:09 +0000 Subject: Set content disposition attachment to several endpoints --- lib/api/helpers.rb | 1 + lib/api/snippets.rb | 1 + 2 files changed, 2 insertions(+) (limited to 'lib/api') 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 -- cgit v1.2.1 From 4bd8a427d4e8127f1badc7365b35702472918956 Mon Sep 17 00:00:00 2001 From: Tiago Botelho Date: Tue, 27 Nov 2018 09:41:27 +0000 Subject: Removes all the irrelevant import related code and columns Clears the import related columns and code from the Project model over to the ProjectImportState model --- lib/api/entities.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib/api') diff --git a/lib/api/entities.rb b/lib/api/entities.rb index cff05643f3b..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] } -- cgit v1.2.1 From 31a1ce2132d83e333e84f365b9aada2e17c61b43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= Date: Fri, 23 Nov 2018 17:25:11 +0100 Subject: Lock writes to trace stream --- lib/api/api.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/api') 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 -- cgit v1.2.1