diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-18 15:08:51 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-18 15:08:51 +0000 |
commit | 163a7046ac76eb4109184e82ce0af911633e6626 (patch) | |
tree | 9f22bb438db435d518e8f5520b309c6319ae0bd8 /lib | |
parent | 0637ba1e6e9024f35b2cbf561d9002ec17350bb3 (diff) | |
download | gitlab-ce-163a7046ac76eb4109184e82ce0af911633e6626.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
7 files changed, 113 insertions, 7 deletions
diff --git a/lib/gitlab/background_migration/user_mentions/create_resource_user_mention.rb b/lib/gitlab/background_migration/user_mentions/create_resource_user_mention.rb index 40f45301727..22b984887b1 100644 --- a/lib/gitlab/background_migration/user_mentions/create_resource_user_mention.rb +++ b/lib/gitlab/background_migration/user_mentions/create_resource_user_mention.rb @@ -21,7 +21,8 @@ module Gitlab records.in_groups_of(BULK_INSERT_SIZE, false).each do |records| mentions = [] records.each do |record| - mentions << record.build_mention_values(resource_user_mention_model.resource_foreign_key) + mention_record = record.build_mention_values(resource_user_mention_model.resource_foreign_key) + mentions << mention_record unless mention_record.blank? end Gitlab::Database.bulk_insert( diff --git a/lib/gitlab/background_migration/user_mentions/models/concerns/isolated_mentionable.rb b/lib/gitlab/background_migration/user_mentions/models/concerns/isolated_mentionable.rb index b7fa92a6686..1fac4b230ca 100644 --- a/lib/gitlab/background_migration/user_mentions/models/concerns/isolated_mentionable.rb +++ b/lib/gitlab/background_migration/user_mentions/models/concerns/isolated_mentionable.rb @@ -68,12 +68,18 @@ module Gitlab def build_mention_values(resource_foreign_key) refs = all_references(author) + mentioned_users_ids = array_to_sql(refs.mentioned_users.pluck(:id)) + mentioned_projects_ids = array_to_sql(refs.mentioned_projects.pluck(:id)) + mentioned_groups_ids = array_to_sql(refs.mentioned_groups.pluck(:id)) + + return if mentioned_users_ids.blank? && mentioned_projects_ids.blank? && mentioned_groups_ids.blank? + { "#{resource_foreign_key}": user_mention_resource_id, note_id: user_mention_note_id, - mentioned_users_ids: array_to_sql(refs.mentioned_users.pluck(:id)), - mentioned_projects_ids: array_to_sql(refs.mentioned_projects.pluck(:id)), - mentioned_groups_ids: array_to_sql(refs.mentioned_groups.pluck(:id)) + mentioned_users_ids: mentioned_users_ids, + mentioned_projects_ids: mentioned_projects_ids, + mentioned_groups_ids: mentioned_groups_ids } end diff --git a/lib/gitlab/background_migration/user_mentions/models/design.rb b/lib/gitlab/background_migration/user_mentions/models/design.rb new file mode 100644 index 00000000000..66cff561bcb --- /dev/null +++ b/lib/gitlab/background_migration/user_mentions/models/design.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true +# rubocop:disable Style/Documentation + +module Gitlab + module BackgroundMigration + module UserMentions + module Models + module DesignManagement + class Design < ActiveRecord::Base + include MentionableMigrationMethods + + def self.user_mention_model + Gitlab::BackgroundMigration::UserMentions::Models::DesignUserMention + end + + def user_mention_model + self.class.user_mention_model + end + + def user_mention_resource_id + id + end + + def user_mention_note_id + 'NULL' + end + end + end + end + end + end +end diff --git a/lib/gitlab/background_migration/user_mentions/models/design_user_mention.rb b/lib/gitlab/background_migration/user_mentions/models/design_user_mention.rb new file mode 100644 index 00000000000..68205ecd3c2 --- /dev/null +++ b/lib/gitlab/background_migration/user_mentions/models/design_user_mention.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true +# rubocop:disable Style/Documentation + +module Gitlab + module BackgroundMigration + module UserMentions + module Models + class DesignUserMention < ActiveRecord::Base + self.table_name = 'design_user_mentions' + + def self.resource_foreign_key + :design_id + end + end + end + end + end +end diff --git a/lib/gitlab/ci/templates/Verify/Accessibility.gitlab-ci.yml b/lib/gitlab/ci/templates/Verify/Accessibility.gitlab-ci.yml new file mode 100644 index 00000000000..a295fdcef7c --- /dev/null +++ b/lib/gitlab/ci/templates/Verify/Accessibility.gitlab-ci.yml @@ -0,0 +1,27 @@ +# Read more about the feature here: https://docs.gitlab.com/ee/user/project/merge_requests/accessibility_testing.html + +stages: + - build + - test + - deploy + - accessibility + +a11y: + stage: accessibility + image: node + script: + - wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \ + - echo "deb http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list && \ + - apt-get update && \ + - apt-get install -y google-chrome-stable && \ + - rm -rf /var/lib/apt/lists/* + - npm install pa11y@5.3.0 pa11y-reporter-html@1.0.0 + - 'echo { \"chromeLaunchConfig\": { \"args\": [\"--no-sandbox\"] }, \"includeWarnings\": true, \"reporter\": \"html\" } > pa11y.json' + - './node_modules/.bin/pa11y $a11y_urls > accessibility.html' + allow_failure: true + artifacts: + when: always + expose_as: 'accessibility' + paths: ['accessibility.html'] + rules: + - if: $a11y_urls diff --git a/lib/gitlab/template/finders/global_template_finder.rb b/lib/gitlab/template/finders/global_template_finder.rb index 2dd4b7a4092..3669d652fd3 100644 --- a/lib/gitlab/template/finders/global_template_finder.rb +++ b/lib/gitlab/template/finders/global_template_finder.rb @@ -5,9 +5,11 @@ module Gitlab module Template module Finders class GlobalTemplateFinder < BaseTemplateFinder - def initialize(base_dir, extension, categories = {}) + def initialize(base_dir, extension, categories = {}, exclusions: []) @categories = categories @extension = extension + @exclusions = exclusions + super(base_dir) end @@ -16,6 +18,8 @@ module Gitlab end def find(key) + return if excluded?(key) + file_name = "#{key}#{@extension}" # The key is untrusted input, so ensure we can't be directed outside @@ -28,11 +32,20 @@ module Gitlab def list_files_for(dir) dir = "#{dir}/" unless dir.end_with?('/') - Dir.glob(File.join(dir, "*#{@extension}")).select { |f| f =~ self.class.filter_regex(@extension) } + + Dir.glob(File.join(dir, "*#{@extension}")).select do |f| + next if excluded?(f) + + f =~ self.class.filter_regex(@extension) + end end private + def excluded?(file_name) + @exclusions.include?(file_name) + end + def select_directory(file_name) @categories.keys.find do |category| File.exist?(File.join(category_directory(category), file_name)) diff --git a/lib/gitlab/template/gitlab_ci_yml_template.rb b/lib/gitlab/template/gitlab_ci_yml_template.rb index ee91f1200cd..26a9dc9fd38 100644 --- a/lib/gitlab/template/gitlab_ci_yml_template.rb +++ b/lib/gitlab/template/gitlab_ci_yml_template.rb @@ -17,16 +17,25 @@ module Gitlab { 'General' => '', 'Pages' => 'Pages', + 'Verify' => 'Verify', 'Auto deploy' => 'autodeploy' } end + def disabled_templates + %w[ + Verify/Browser-Performance + ] + end + def base_dir Rails.root.join('lib/gitlab/ci/templates') end def finder(project = nil) - Gitlab::Template::Finders::GlobalTemplateFinder.new(self.base_dir, self.extension, self.categories) + Gitlab::Template::Finders::GlobalTemplateFinder.new( + self.base_dir, self.extension, self.categories, exclusions: self.disabled_templates + ) end end end |