diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-05 09:07:37 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-05 09:07:37 +0000 |
commit | cf98b5d69a84324cad0f23b786a0ec0937c90944 (patch) | |
tree | 96a65fa7e9f4560ca87fd3db9e9072ae46e14639 /app | |
parent | 5fd38b5f78df56538ff4362f7be734c65891f2d8 (diff) | |
download | gitlab-ce-cf98b5d69a84324cad0f23b786a0ec0937c90944.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/diffs/components/collapsed_files_warning.vue | 7 | ||||
-rw-r--r-- | app/finders/security/jobs_finder.rb | 2 | ||||
-rw-r--r-- | app/models/blob_viewer/markup.rb | 4 | ||||
-rw-r--r-- | app/services/projects/overwrite_project_service.rb | 2 | ||||
-rw-r--r-- | app/services/releases/base_service.rb | 11 | ||||
-rw-r--r-- | app/services/releases/create_service.rb | 2 | ||||
-rw-r--r-- | app/services/releases/destroy_service.rb | 2 | ||||
-rw-r--r-- | app/services/releases/update_service.rb | 2 | ||||
-rw-r--r-- | app/uploaders/dependency_proxy/file_uploader.rb | 2 |
9 files changed, 27 insertions, 7 deletions
diff --git a/app/assets/javascripts/diffs/components/collapsed_files_warning.vue b/app/assets/javascripts/diffs/components/collapsed_files_warning.vue index 0cf1cdb17f8..240f102e600 100644 --- a/app/assets/javascripts/diffs/components/collapsed_files_warning.vue +++ b/app/assets/javascripts/diffs/components/collapsed_files_warning.vue @@ -1,5 +1,6 @@ <script> import { GlAlert, GlButton } from '@gitlab/ui'; +import { mapState } from 'vuex'; import { CENTERED_LIMITED_CONTAINER_CLASSES, EVT_EXPAND_ALL_FILES } from '../constants'; import eventHub from '../event_hub'; @@ -27,11 +28,15 @@ export default { }; }, computed: { + ...mapState('diffs', ['diffFiles']), containerClasses() { return { [CENTERED_LIMITED_CONTAINER_CLASSES]: this.limited, }; }, + shouldDisplay() { + return !this.isDismissed && this.diffFiles.length > 1; + }, }, methods: { @@ -48,7 +53,7 @@ export default { </script> <template> - <div v-if="!isDismissed" data-testid="root" :class="containerClasses" class="col-12"> + <div v-if="shouldDisplay" data-testid="root" :class="containerClasses" class="col-12"> <gl-alert :dismissible="true" :title="__('Some changes are not shown')" diff --git a/app/finders/security/jobs_finder.rb b/app/finders/security/jobs_finder.rb index cffc1d52a3e..99bcf97f43c 100644 --- a/app/finders/security/jobs_finder.rb +++ b/app/finders/security/jobs_finder.rb @@ -20,7 +20,7 @@ module Security end def initialize(pipeline:, job_types: []) - if self.class == Security::JobsFinder + if self.instance_of?(Security::JobsFinder) raise NotImplementedError, 'This is an abstract class, please instantiate its descendants' end diff --git a/app/models/blob_viewer/markup.rb b/app/models/blob_viewer/markup.rb index 37a8e01d0f1..6f002a6b224 100644 --- a/app/models/blob_viewer/markup.rb +++ b/app/models/blob_viewer/markup.rb @@ -14,9 +14,7 @@ module BlobViewer {}.tap do |h| h[:rendered] = blob.rendered_markup if blob.respond_to?(:rendered_markup) - if Feature.enabled?(:cached_markdown_blob, blob.project, default_enabled: true) - h[:cache_key] = ['blob', blob.id, 'commit', blob.commit_id] - end + h[:cache_key] = ['blob', blob.id, 'commit', blob.commit_id] end end end diff --git a/app/services/projects/overwrite_project_service.rb b/app/services/projects/overwrite_project_service.rb index e681b5643ee..6be3b1b5a6f 100644 --- a/app/services/projects/overwrite_project_service.rb +++ b/app/services/projects/overwrite_project_service.rb @@ -20,7 +20,7 @@ module Projects rescue Exception => e # rubocop:disable Lint/RescueException attempt_restore_repositories(source_project) - if e.class == Exception + if e.instance_of?(Exception) raise StandardError, e.message else raise diff --git a/app/services/releases/base_service.rb b/app/services/releases/base_service.rb index 9dd0c9a007a..b4b493624e7 100644 --- a/app/services/releases/base_service.rb +++ b/app/services/releases/base_service.rb @@ -5,6 +5,8 @@ module Releases include BaseServiceUtility include Gitlab::Utils::StrongMemoize + ReleaseProtectedTagAccessError = Class.new(StandardError) + attr_accessor :project, :current_user, :params def initialize(project, user = nil, params = {}) @@ -81,6 +83,15 @@ module Releases release.execute_hooks(action) end + def track_protected_tag_access_error! + unless ::Gitlab::UserAccess.new(current_user, container: project).can_create_tag?(tag_name) + Gitlab::ErrorTracking.log_exception( + ReleaseProtectedTagAccessError.new, + project_id: project.id, + user_id: current_user.id) + end + end + # overridden in EE def project_group_id; end end diff --git a/app/services/releases/create_service.rb b/app/services/releases/create_service.rb index 1096e207e02..52d95872414 100644 --- a/app/services/releases/create_service.rb +++ b/app/services/releases/create_service.rb @@ -7,6 +7,8 @@ module Releases return error('Release already exists', 409) if release return error("Milestone(s) not found: #{inexistent_milestones.join(', ')}", 400) if inexistent_milestones.any? + track_protected_tag_access_error! + # should be found before the creation of new tag # because tag creation can spawn new pipeline # which won't have any data for evidence yet diff --git a/app/services/releases/destroy_service.rb b/app/services/releases/destroy_service.rb index 8abf9308689..36cf29c955d 100644 --- a/app/services/releases/destroy_service.rb +++ b/app/services/releases/destroy_service.rb @@ -6,6 +6,8 @@ module Releases return error('Release does not exist', 404) unless release return error('Access Denied', 403) unless allowed? + track_protected_tag_access_error! + if release.destroy success(tag: existing_tag, release: release) else diff --git a/app/services/releases/update_service.rb b/app/services/releases/update_service.rb index 4e78120ac05..eda4b7102c0 100644 --- a/app/services/releases/update_service.rb +++ b/app/services/releases/update_service.rb @@ -7,6 +7,8 @@ module Releases return error end + track_protected_tag_access_error! + if param_for_milestone_titles_provided? previous_milestones = release.milestones.map(&:title) params[:milestones] = milestones diff --git a/app/uploaders/dependency_proxy/file_uploader.rb b/app/uploaders/dependency_proxy/file_uploader.rb index c46539bafaa..5154f180454 100644 --- a/app/uploaders/dependency_proxy/file_uploader.rb +++ b/app/uploaders/dependency_proxy/file_uploader.rb @@ -24,7 +24,7 @@ class DependencyProxy::FileUploader < GitlabUploader # so we must store the custom content type in object storage. # This does not apply to DependencyProxy::Blob uploads. def set_content_type(file) - return unless model.class == DependencyProxy::Manifest + return unless model.instance_of?(DependencyProxy::Manifest) file.content_type = model.content_type end |