diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-12 12:06:14 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-12 12:06:14 +0300 |
commit | 7801d133b6c33917a3a151c7a8db5243b148a487 (patch) | |
tree | 7a8fbb7dd66875acd0adb490dc91aa91c0802987 /lib | |
parent | 60877d1bff65fa4d2b74409d343d5b7615478891 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/branches.rb | 2 | ||||
-rw-r--r-- | lib/api/entities.rb | 4 | ||||
-rw-r--r-- | lib/api/group_container_repositories.rb | 2 | ||||
-rw-r--r-- | lib/api/helpers.rb | 11 | ||||
-rw-r--r-- | lib/api/project_container_repositories.rb | 9 |
5 files changed, 25 insertions, 3 deletions
diff --git a/lib/api/branches.rb b/lib/api/branches.rb index f8f79ab6f5a..054242dca4c 100644 --- a/lib/api/branches.rb +++ b/lib/api/branches.rb @@ -32,7 +32,7 @@ module API use :filter_params end get ':id/repository/branches' do - Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42329') + user_project.preload_protected_branches repository = user_project.repository diff --git a/lib/api/entities.rb b/lib/api/entities.rb index e6429725757..5819b366f7f 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -489,11 +489,11 @@ module API end expose :developers_can_push do |repo_branch, options| - options[:project].protected_branches.developers_can?(:push, repo_branch.name) + ::ProtectedBranch.developers_can?(:push, repo_branch.name, protected_refs: options[:project].protected_branches) end expose :developers_can_merge do |repo_branch, options| - options[:project].protected_branches.developers_can?(:merge, repo_branch.name) + ::ProtectedBranch.developers_can?(:merge, repo_branch.name, protected_refs: options[:project].protected_branches) end expose :can_push do |repo_branch, options| diff --git a/lib/api/group_container_repositories.rb b/lib/api/group_container_repositories.rb index d1aaafec8aa..7f95b411b36 100644 --- a/lib/api/group_container_repositories.rb +++ b/lib/api/group_container_repositories.rb @@ -26,6 +26,8 @@ module API user: current_user, subject: user_group ).execute + track_event('list_repositories') + present paginate(repositories), with: Entities::ContainerRegistry::Repository, tags: params[:tags] end end diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index e740134f85f..ca49687081d 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -455,6 +455,17 @@ module API end end + def track_event(action = action_name, **args) + category = args.delete(:category) || self.options[:for].name + raise "invalid category" unless category + + ::Gitlab::Tracking.event(category, action.to_s, **args) + rescue => error + Rails.logger.warn( # rubocop:disable Gitlab/RailsLogger + "Tracking event failed for action: #{action}, category: #{category}, message: #{error.message}" + ) + end + protected def project_finder_params_ce diff --git a/lib/api/project_container_repositories.rb b/lib/api/project_container_repositories.rb index c7731b70f39..2b33069e324 100644 --- a/lib/api/project_container_repositories.rb +++ b/lib/api/project_container_repositories.rb @@ -27,6 +27,8 @@ module API user: current_user, subject: user_project ).execute + track_event( 'list_repositories') + present paginate(repositories), with: Entities::ContainerRegistry::Repository, tags: params[:tags] end @@ -40,6 +42,7 @@ module API authorize_admin_container_image! DeleteContainerRepositoryWorker.perform_async(current_user.id, repository.id) + track_event('delete_repository') status :accepted end @@ -56,6 +59,8 @@ module API authorize_read_container_image! tags = Kaminari.paginate_array(repository.tags) + track_event('list_tags') + present paginate(tags), with: Entities::ContainerRegistry::Tag end @@ -77,6 +82,8 @@ module API CleanupContainerRepositoryWorker.perform_async(current_user.id, repository.id, declared_params.except(:repository_id)) + track_event('delete_tag_bulk') + status :accepted end @@ -111,6 +118,8 @@ module API .execute(repository) if result[:status] == :success + track_event('delete_tag') + status :ok else status :bad_request |