From 3462d7613fb761a4cbf2904c6980fd39b6f8bd5f Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 7 Jul 2021 00:07:23 +0000 Subject: [PATCH] Add latest changes from gitlab-org/gitlab@master --- GITALY_SERVER_VERSION | 2 +- .../vue_shared/components/awards_list.vue | 8 +- .../environments/environments_finder.rb | 9 + .../one_megabyte_file_size_limit.yml | 8 + config/initializers/7_prometheus_metrics.rb | 2 +- db/ci_schema_migrations/20210617101848 | 1 + db/ci_structure.sql | 96 +-- ...e_push_event_payloads_bigint_conversion.rb | 8 + ...event_id_back_to_integer_for_gitlab_com.rb | 15 + db/schema_migrations/20210630025020 | 1 + db/structure.sql | 8 +- doc/api/graphql/reference/index.md | 1 + .../dump_schema_versions_mixin.rb | 5 +- .../load_schema_versions_mixin.rb | 8 +- lib/gitlab/database/schema_cleaner.rb | 6 +- lib/gitlab/database/schema_migrations.rb | 19 + .../database/schema_migrations/context.rb | 41 + .../database/schema_migrations/migrations.rb | 52 ++ lib/gitlab/database/schema_version_files.rb | 64 -- lib/gitlab/highlight.rb | 16 +- .../kubernetes/cilium_network_policy.rb | 10 +- lib/gitlab/kubernetes/network_policy.rb | 12 +- .../kubernetes/network_policy_common.rb | 3 +- lib/gitlab/path_regex.rb | 4 +- lib/tasks/gitlab/db.rake | 11 +- locale/gitlab.pot | 5 +- .../issues/user_interacts_with_awards_spec.rb | 2 +- .../environments/environments_finder_spec.rb | 31 +- .../database/structure_example_cleaned.sql | 4 +- .../__snapshots__/awards_list_spec.js.snap | 14 +- .../vue_shared/components/awards_list_spec.js | 18 +- .../dump_schema_versions_mixin_spec.rb | 45 +- .../load_schema_versions_mixin_spec.rb | 29 +- .../schema_migrations/context_spec.rb | 78 ++ .../migrations_spec.rb} | 41 +- spec/lib/gitlab/highlight_spec.rb | 7 + .../kubernetes/cilium_network_policy_spec.rb | 8 + .../gitlab/kubernetes/network_policy_spec.rb | 8 + spec/lib/gitlab/path_regex_spec.rb | 2 + spec/requests/git_http_spec.rb | 716 ++++++++++++++++++ .../network_policy_common_shared_examples.rb | 3 +- spec/tasks/gitlab/db_rake_spec.rb | 17 +- 42 files changed, 1115 insertions(+), 323 deletions(-) create mode 100644 config/feature_flags/development/one_megabyte_file_size_limit.yml create mode 100644 db/ci_schema_migrations/20210617101848 create mode 100644 db/post_migrate/20210630025020_migrate_push_event_payloads_event_id_back_to_integer_for_gitlab_com.rb create mode 100644 db/schema_migrations/20210630025020 create mode 100644 lib/gitlab/database/schema_migrations.rb create mode 100644 lib/gitlab/database/schema_migrations/context.rb create mode 100644 lib/gitlab/database/schema_migrations/migrations.rb delete mode 100644 lib/gitlab/database/schema_version_files.rb create mode 100644 spec/lib/gitlab/database/schema_migrations/context_spec.rb rename spec/lib/gitlab/database/{schema_version_files_spec.rb => schema_migrations/migrations_spec.rb} (60%) diff --git a/GITALY_SERVER_VERSION b/GITALY_SERVER_VERSION index 5ecf28e18f9..cdd00724681 100644 --- a/GITALY_SERVER_VERSION +++ b/GITALY_SERVER_VERSION @@ -1 +1 @@ -d12fb69a841d91d843f392a124865f6d47d3bc22 +747d61c17a51f361cc883c9d4700e174219088a5 diff --git a/app/assets/javascripts/vue_shared/components/awards_list.vue b/app/assets/javascripts/vue_shared/components/awards_list.vue index e6d9a38d1fb..f4c73d12923 100644 --- a/app/assets/javascripts/vue_shared/components/awards_list.vue +++ b/app/assets/javascripts/vue_shared/components/awards_list.vue @@ -93,12 +93,12 @@ export default { return { name, list, - title: this.getAwardListTitle(list), + title: this.getAwardListTitle(list, name), classes: this.getAwardClassBindings(list), html: glEmojiTag(name), }; }, - getAwardListTitle(awardsList) { + getAwardListTitle(awardsList, name) { if (!awardsList.length) { return ''; } @@ -128,7 +128,7 @@ export default { // We have 10+ awarded user, join them with comma and add `and x more`. if (remainingAwardList.length) { title = sprintf( - __(`%{listToShow}, and %{awardsListLength} more.`), + __(`%{listToShow}, and %{awardsListLength} more`), { listToShow: namesToShow.join(', '), awardsListLength: remainingAwardList.length, @@ -146,7 +146,7 @@ export default { title = namesToShow.join(__(' and ')); } - return title; + return title + sprintf(__(' reacted with :%{name}:'), { name }); }, handleAward(awardName) { if (!this.canAwardEmoji) { diff --git a/app/finders/environments/environments_finder.rb b/app/finders/environments/environments_finder.rb index 190cdb3dec3..46c49f096c6 100644 --- a/app/finders/environments/environments_finder.rb +++ b/app/finders/environments/environments_finder.rb @@ -16,6 +16,7 @@ module Environments environments = project.environments environments = by_name(environments) environments = by_search(environments) + environments = by_ids(environments) # Raises InvalidStatesError if params[:states] contains invalid states. by_states(environments) @@ -47,6 +48,14 @@ module Environments end end + def by_ids(environments) + if params[:environment_ids].present? + environments.for_id(params[:environment_ids]) + else + environments + end + end + def environments_with_states(environments) # Convert to array of strings states = Array(params[:states]).map(&:to_s) diff --git a/config/feature_flags/development/one_megabyte_file_size_limit.yml b/config/feature_flags/development/one_megabyte_file_size_limit.yml new file mode 100644 index 00000000000..2bebebf8220 --- /dev/null +++ b/config/feature_flags/development/one_megabyte_file_size_limit.yml @@ -0,0 +1,8 @@ +--- +name: one_megabyte_file_size_limit +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/65167 +rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/334916 +milestone: '14.1' +type: development +group: group::code review +default_enabled: false diff --git a/config/initializers/7_prometheus_metrics.rb b/config/initializers/7_prometheus_metrics.rb index f3fe61d2f92..fc69ae7b077 100644 --- a/config/initializers/7_prometheus_metrics.rb +++ b/config/initializers/7_prometheus_metrics.rb @@ -49,7 +49,7 @@ if !Rails.env.test? && Gitlab::Metrics.prometheus_metrics_enabled? Gitlab::Metrics::Samplers::PumaSampler.instance.start end - Gitlab::Metrics.gauge(:deployments, 'GitLab Version', {}, :max).set({ version: Gitlab::VERSION }, 1) + Gitlab::Metrics.gauge(:deployments, 'GitLab Version', {}, :max).set({ version: Gitlab::VERSION, revision: Gitlab.revision }, 1) unless Gitlab::Runtime.sidekiq? Gitlab::Metrics::RequestsRackMiddleware.initialize_metrics diff --git a/db/ci_schema_migrations/20210617101848 b/db/ci_schema_migrations/20210617101848 new file mode 100644 index 00000000000..2969c694fa2 --- /dev/null +++ b/db/ci_schema_migrations/20210617101848 @@ -0,0 +1 @@ +1b74312f59f6f8937cd0dd754d22dc72e9bdc7302e6254a2fda5762afebe303c \ No newline at end of file diff --git a/db/ci_structure.sql b/db/ci_structure.sql index 16e2d25e507..1b898012f46 100644 --- a/db/ci_structure.sql +++ b/db/ci_structure.sql @@ -1,35 +1,11 @@ -SET statement_timeout = 0; -SET lock_timeout = 0; -SET idle_in_transaction_session_timeout = 0; -SET client_encoding = 'UTF8'; -SET standard_conforming_strings = on; -SELECT pg_catalog.set_config('search_path', '', false); -SET check_function_bodies = false; -SET xmloption = content; -SET client_min_messages = warning; -SET row_security = off; - -SET default_tablespace = ''; - -SET default_table_access_method = heap; - --- --- Name: ar_internal_metadata; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.ar_internal_metadata ( +CREATE TABLE ar_internal_metadata ( key character varying NOT NULL, value character varying, created_at timestamp(6) without time zone NOT NULL, updated_at timestamp(6) without time zone NOT NULL ); - --- --- Name: ci_instance_variables; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.ci_instance_variables ( +CREATE TABLE ci_instance_variables ( id bigint NOT NULL, variable_type smallint DEFAULT 1 NOT NULL, masked boolean DEFAULT false, @@ -42,80 +18,28 @@ CREATE TABLE public.ci_instance_variables ( CONSTRAINT check_956afd70f1 CHECK ((char_length(encrypted_value) <= 13579)) ); - --- --- Name: ci_instance_variables_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.ci_instance_variables_id_seq +CREATE SEQUENCE ci_instance_variables_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; +ALTER SEQUENCE ci_instance_variables_id_seq OWNED BY ci_instance_variables.id; --- --- Name: ci_instance_variables_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.ci_instance_variables_id_seq OWNED BY public.ci_instance_variables.id; - - --- --- Name: schema_migrations; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.schema_migrations ( +CREATE TABLE schema_migrations ( version character varying NOT NULL ); +ALTER TABLE ONLY ci_instance_variables ALTER COLUMN id SET DEFAULT nextval('ci_instance_variables_id_seq'::regclass); --- --- Name: ci_instance_variables id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.ci_instance_variables ALTER COLUMN id SET DEFAULT nextval('public.ci_instance_variables_id_seq'::regclass); - - --- --- Name: ar_internal_metadata ar_internal_metadata_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.ar_internal_metadata +ALTER TABLE ONLY ar_internal_metadata ADD CONSTRAINT ar_internal_metadata_pkey PRIMARY KEY (key); - --- --- Name: ci_instance_variables ci_instance_variables_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.ci_instance_variables +ALTER TABLE ONLY ci_instance_variables ADD CONSTRAINT ci_instance_variables_pkey PRIMARY KEY (id); - --- --- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.schema_migrations +ALTER TABLE ONLY schema_migrations ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version); - --- --- Name: index_ci_instance_variables_on_key; Type: INDEX; Schema: public; Owner: - --- - -CREATE UNIQUE INDEX index_ci_instance_variables_on_key ON public.ci_instance_variables USING btree (key); - - --- --- PostgreSQL database dump complete --- - -SET search_path TO "$user", public; - -INSERT INTO "schema_migrations" (version) VALUES -('20210617101848'); - - +CREATE UNIQUE INDEX index_ci_instance_variables_on_key ON ci_instance_variables USING btree (key); diff --git a/db/post_migrate/20210622041846_finalize_push_event_payloads_bigint_conversion.rb b/db/post_migrate/20210622041846_finalize_push_event_payloads_bigint_conversion.rb index c80ce4417f3..38b081e3e5e 100644 --- a/db/post_migrate/20210622041846_finalize_push_event_payloads_bigint_conversion.rb +++ b/db/post_migrate/20210622041846_finalize_push_event_payloads_bigint_conversion.rb @@ -9,6 +9,8 @@ class FinalizePushEventPayloadsBigintConversion < ActiveRecord::Migration[6.1] INDEX_NAME = 'index_push_event_payloads_on_event_id_convert_to_bigint' def up + return unless should_run? + ensure_batched_background_migration_is_finished( job_class_name: 'CopyColumnUsingBackgroundMigrationJob', table_name: TABLE_NAME, @@ -20,11 +22,17 @@ class FinalizePushEventPayloadsBigintConversion < ActiveRecord::Migration[6.1] end def down + return unless should_run? + swap_columns end private + def should_run? + Gitlab.dev_or_test_env? || Gitlab.com? + end + def swap_columns add_concurrent_index TABLE_NAME, :event_id_convert_to_bigint, unique: true, name: INDEX_NAME diff --git a/db/post_migrate/20210630025020_migrate_push_event_payloads_event_id_back_to_integer_for_gitlab_com.rb b/db/post_migrate/20210630025020_migrate_push_event_payloads_event_id_back_to_integer_for_gitlab_com.rb new file mode 100644 index 00000000000..834a23a5c7a --- /dev/null +++ b/db/post_migrate/20210630025020_migrate_push_event_payloads_event_id_back_to_integer_for_gitlab_com.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require Rails.root.join('db', 'post_migrate', '20210622041846_finalize_push_event_payloads_bigint_conversion') + +class MigratePushEventPayloadsEventIdBackToIntegerForGitlabCom < ActiveRecord::Migration[6.1] + disable_ddl_transaction! + + def up + FinalizePushEventPayloadsBigintConversion.new.down + end + + def down + FinalizePushEventPayloadsBigintConversion.new.up + end +end diff --git a/db/schema_migrations/20210630025020 b/db/schema_migrations/20210630025020 new file mode 100644 index 00000000000..7808a7e3178 --- /dev/null +++ b/db/schema_migrations/20210630025020 @@ -0,0 +1 @@ +71ad8c8f2419721f8fdf6c6bbd1265c4a7ca277972c59319e155bc6dfc46aa48 \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 249c61dbfd3..8cd143359e5 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -17376,7 +17376,7 @@ ALTER SEQUENCE protected_tags_id_seq OWNED BY protected_tags.id; CREATE TABLE push_event_payloads ( commit_count bigint NOT NULL, - event_id_convert_to_bigint integer DEFAULT 0 NOT NULL, + event_id integer NOT NULL, action smallint NOT NULL, ref_type smallint NOT NULL, commit_from bytea, @@ -17384,7 +17384,7 @@ CREATE TABLE push_event_payloads ( ref text, commit_title character varying(70), ref_count integer, - event_id bigint NOT NULL + event_id_convert_to_bigint bigint DEFAULT 0 NOT NULL ); CREATE TABLE push_rules ( @@ -27974,6 +27974,4 @@ ALTER TABLE ONLY user_follow_users ADD CONSTRAINT user_follow_users_followee_id_fkey FOREIGN KEY (followee_id) REFERENCES users(id) ON DELETE CASCADE; ALTER TABLE ONLY user_follow_users - ADD CONSTRAINT user_follow_users_follower_id_fkey FOREIGN KEY (follower_id) REFERENCES users(id) ON DELETE CASCADE;-- schema_migrations.version information is no longer stored in this file, --- but instead tracked in the db/schema_migrations directory --- see https://gitlab.com/gitlab-org/gitlab/-/issues/218590 for details + ADD CONSTRAINT user_follow_users_follower_id_fkey FOREIGN KEY (follower_id) REFERENCES users(id) ON DELETE CASCADE; diff --git a/doc/api/graphql/reference/index.md b/doc/api/graphql/reference/index.md index b2bc8dec505..803e8a3b44b 100644 --- a/doc/api/graphql/reference/index.md +++ b/doc/api/graphql/reference/index.md @@ -10949,6 +10949,7 @@ Represents the network policy. | Name | Type | Description | | ---- | ---- | ----------- | | `enabled` | [`Boolean!`](#boolean) | Indicates whether this policy is enabled. | +| `environments` | [`EnvironmentConnection`](#environmentconnection) | Environments where this policy is applied. (see [Connections](#connections)) | | `fromAutoDevops` | [`Boolean!`](#boolean) | Indicates whether this policy is created from AutoDevops. | | `name` | [`String!`](#string) | Name of the policy. | | `namespace` | [`String!`](#string) | Namespace of the policy. | diff --git a/lib/gitlab/database/postgresql_adapter/dump_schema_versions_mixin.rb b/lib/gitlab/database/postgresql_adapter/dump_schema_versions_mixin.rb index 4cb7b516612..a2e7f4befab 100644 --- a/lib/gitlab/database/postgresql_adapter/dump_schema_versions_mixin.rb +++ b/lib/gitlab/database/postgresql_adapter/dump_schema_versions_mixin.rb @@ -7,10 +7,7 @@ module Gitlab extend ActiveSupport::Concern def dump_schema_information # :nodoc: - return super unless ActiveRecord::Base.configurations.primary?(pool.db_config.name) - - versions = schema_migration.all_versions - Gitlab::Database::SchemaVersionFiles.touch_all(versions) if versions.any? + Gitlab::Database::SchemaMigrations.touch_all(self) nil end diff --git a/lib/gitlab/database/postgresql_database_tasks/load_schema_versions_mixin.rb b/lib/gitlab/database/postgresql_database_tasks/load_schema_versions_mixin.rb index 6914b7ea4fc..30060ecb34f 100644 --- a/lib/gitlab/database/postgresql_database_tasks/load_schema_versions_mixin.rb +++ b/lib/gitlab/database/postgresql_database_tasks/load_schema_versions_mixin.rb @@ -7,13 +7,9 @@ module Gitlab extend ActiveSupport::Concern def structure_load(...) - result = super(...) + super(...) - if ActiveRecord::Base.configurations.primary?(connection.pool.db_config.name) - Gitlab::Database::SchemaVersionFiles.load_all - else - result - end + Gitlab::Database::SchemaMigrations.load_all(connection) end end end diff --git a/lib/gitlab/database/schema_cleaner.rb b/lib/gitlab/database/schema_cleaner.rb index 8f93da2b66c..c3cdcf1450d 100644 --- a/lib/gitlab/database/schema_cleaner.rb +++ b/lib/gitlab/database/schema_cleaner.rb @@ -30,11 +30,7 @@ module Gitlab structure.gsub!(/\n{3,}/, "\n\n") io << structure.strip - io << <<~MSG - -- schema_migrations.version information is no longer stored in this file, - -- but instead tracked in the db/schema_migrations directory - -- see https://gitlab.com/gitlab-org/gitlab/-/issues/218590 for details - MSG + io << "\n" nil end diff --git a/lib/gitlab/database/schema_migrations.rb b/lib/gitlab/database/schema_migrations.rb new file mode 100644 index 00000000000..1c49ed8d946 --- /dev/null +++ b/lib/gitlab/database/schema_migrations.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module Gitlab + module Database + module SchemaMigrations + def self.touch_all(connection) + context = Gitlab::Database::SchemaMigrations::Context.new(connection) + + Gitlab::Database::SchemaMigrations::Migrations.new(context).touch_all + end + + def self.load_all(connection) + context = Gitlab::Database::SchemaMigrations::Context.new(connection) + + Gitlab::Database::SchemaMigrations::Migrations.new(context).load_all + end + end + end +end diff --git a/lib/gitlab/database/schema_migrations/context.rb b/lib/gitlab/database/schema_migrations/context.rb new file mode 100644 index 00000000000..bd8b9bed2c1 --- /dev/null +++ b/lib/gitlab/database/schema_migrations/context.rb @@ -0,0 +1,41 @@ +# frozen_string_literal: true + +module Gitlab + module Database + module SchemaMigrations + class Context + attr_reader :connection + + def initialize(connection) + @connection = connection + end + + def schema_directory + @schema_directory ||= + if ActiveRecord::Base.configurations.primary?(database_name) + File.join(db_dir, 'schema_migrations') + else + File.join(db_dir, "#{database_name}_schema_migrations") + end + end + + def versions_to_create + versions_from_database = @connection.schema_migration.all_versions + versions_from_migration_files = @connection.migration_context.migrations.map { |m| m.version.to_s } + + versions_from_database & versions_from_migration_files + end + + private + + def database_name + @database_name ||= @connection.pool.db_config.name + end + + def db_dir + @db_dir ||= Rails.application.config.paths["db"].first + end + end + end + end +end diff --git a/lib/gitlab/database/schema_migrations/migrations.rb b/lib/gitlab/database/schema_migrations/migrations.rb new file mode 100644 index 00000000000..3b16b7f1b81 --- /dev/null +++ b/lib/gitlab/database/schema_migrations/migrations.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +module Gitlab + module Database + module SchemaMigrations + class Migrations + MIGRATION_VERSION_GLOB = '20[0-9][0-9]*' + + def initialize(context) + @context = context + end + + def touch_all + return unless @context.versions_to_create.any? + + version_filepaths = version_filenames.map { |f| File.join(schema_directory, f) } + FileUtils.rm(version_filepaths) + + @context.versions_to_create.each do |version| + version_filepath = File.join(schema_directory, version) + + File.open(version_filepath, 'w') do |file| + file << Digest::SHA256.hexdigest(version) + end + end + end + + def load_all + return if version_filenames.empty? + + values = version_filenames.map { |vf| "('#{@context.connection.quote_string(vf)}')" } + + @context.connection.execute(<<~SQL) + INSERT INTO schema_migrations (version) + VALUES #{values.join(',')} + ON CONFLICT DO NOTHING + SQL + end + + private + + def schema_directory + @context.schema_directory + end + + def version_filenames + @version_filenames ||= Dir.glob(MIGRATION_VERSION_GLOB, base: schema_directory) + end + end + end + end +end diff --git a/lib/gitlab/database/schema_version_files.rb b/lib/gitlab/database/schema_version_files.rb deleted file mode 100644 index 27a942404ef..00000000000 --- a/lib/gitlab/database/schema_version_files.rb +++ /dev/null @@ -1,64 +0,0 @@ -# frozen_string_literal: true - -module Gitlab - module Database - class SchemaVersionFiles - SCHEMA_DIRECTORY = 'db/schema_migrations' - MIGRATION_DIRECTORIES = %w[db/migrate db/post_migrate].freeze - MIGRATION_VERSION_GLOB = '20[0-9][0-9]*' - - def self.touch_all(versions_from_database) - versions_from_migration_files = find_versions_from_migration_files - - version_filepaths = find_version_filenames.map { |f| schema_directory.join(f) } - FileUtils.rm(version_filepaths) - - versions_to_create = versions_from_database & versions_from_migration_files - versions_to_create.each do |version| - version_filepath = schema_directory.join(version) - - File.open(version_filepath, 'w') do |file| - file << Digest::SHA256.hexdigest(version) - end - end - end - - def self.load_all - version_filenames = find_version_filenames - return if version_filenames.empty? - - values = version_filenames.map { |vf| "('#{connection.quote_string(vf)}')" } - connection.execute(<<~SQL) - INSERT INTO schema_migrations (version) - VALUES #{values.join(',')} - ON CONFLICT DO NOTHING - SQL - end - - def self.schema_directory - @schema_directory ||= Rails.root.join(SCHEMA_DIRECTORY) - end - - def self.migration_directories - @migration_directories ||= MIGRATION_DIRECTORIES.map { |dir| Rails.root.join(dir) } - end - - def self.find_version_filenames - Dir.glob(MIGRATION_VERSION_GLOB, base: schema_directory) - end - - def self.find_versions_from_migration_files - migration_directories.each_with_object([]) do |directory, migration_versions| - directory_migrations = Dir.glob(MIGRATION_VERSION_GLOB, base: directory) - directory_versions = directory_migrations.map! { |m| m.split('_').first } - - migration_versions.concat(directory_versions) - end - end - - def self.connection - ActiveRecord::Base.connection - end - end - end -end diff --git a/lib/gitlab/highlight.rb b/lib/gitlab/highlight.rb index d05ced00a6b..afe1554aec1 100644 --- a/lib/gitlab/highlight.rb +++ b/lib/gitlab/highlight.rb @@ -11,11 +11,9 @@ module Gitlab end def self.too_large?(size) - file_size_limit = Gitlab.config.extra['maximum_text_highlight_size_kilobytes'] + return false unless size.to_i > self.file_size_limit - return false unless size.to_i > file_size_limit - - over_highlight_size_limit.increment(source: "file size: #{file_size_limit}") if Feature.enabled?(:track_file_size_over_highlight_limit) + over_highlight_size_limit.increment(source: "file size: #{self.file_size_limit}") if Feature.enabled?(:track_file_size_over_highlight_limit) true end @@ -51,6 +49,16 @@ module Gitlab attr_reader :context + def self.file_size_limit + if Feature.enabled?(:one_megabyte_file_size_limit) + 1024.kilobytes + else + Gitlab.config.extra['maximum_text_highlight_size_kilobytes'] + end + end + + private_class_method :file_size_limit + def custom_language return unless @language diff --git a/lib/gitlab/kubernetes/cilium_network_policy.rb b/lib/gitlab/kubernetes/cilium_network_policy.rb index f77b3e8de99..e333d3818b9 100644 --- a/lib/gitlab/kubernetes/cilium_network_policy.rb +++ b/lib/gitlab/kubernetes/cilium_network_policy.rb @@ -12,7 +12,7 @@ module Gitlab # We are modeling existing kubernetes resource and don't have # control over amount of parameters. # rubocop:disable Metrics/ParameterLists - def initialize(name:, namespace:, selector:, ingress:, resource_version: nil, description: nil, labels: nil, creation_timestamp: nil, egress: nil, annotations: nil) + def initialize(name:, namespace:, selector:, ingress:, resource_version: nil, description: nil, labels: nil, creation_timestamp: nil, egress: nil, annotations: nil, environment_ids: []) @name = name @description = description @namespace = namespace @@ -23,6 +23,7 @@ module Gitlab @ingress = ingress @egress = egress @annotations = annotations + @environment_ids = environment_ids end # rubocop:enable Metrics/ParameterLists @@ -49,7 +50,7 @@ module Gitlab nil end - def self.from_resource(resource) + def self.from_resource(resource, environment_ids = []) return unless resource return if !resource[:metadata] || !resource[:spec] @@ -65,7 +66,8 @@ module Gitlab creation_timestamp: metadata[:creationTimestamp], selector: spec[:endpointSelector], ingress: spec[:ingress], - egress: spec[:egress] + egress: spec[:egress], + environment_ids: environment_ids ) end @@ -83,7 +85,7 @@ module Gitlab private - attr_reader :name, :description, :namespace, :labels, :creation_timestamp, :resource_version, :ingress, :egress, :annotations + attr_reader :name, :description, :namespace, :labels, :creation_timestamp, :resource_version, :ingress, :egress, :annotations, :environment_ids def selector @selector ||= {} diff --git a/lib/gitlab/kubernetes/network_policy.rb b/lib/gitlab/kubernetes/network_policy.rb index c8e9b987443..e6111db5b17 100644 --- a/lib/gitlab/kubernetes/network_policy.rb +++ b/lib/gitlab/kubernetes/network_policy.rb @@ -8,7 +8,8 @@ module Gitlab KIND = 'NetworkPolicy' - def initialize(name:, namespace:, selector:, ingress:, labels: nil, creation_timestamp: nil, policy_types: ["Ingress"], egress: nil) + # rubocop:disable Metrics/ParameterLists + def initialize(name:, namespace:, selector:, ingress:, labels: nil, creation_timestamp: nil, policy_types: ["Ingress"], egress: nil, environment_ids: []) @name = name @namespace = namespace @labels = labels @@ -17,7 +18,9 @@ module Gitlab @policy_types = policy_types @ingress = ingress @egress = egress + @environment_ids = environment_ids end + # rubocop:enable Metrics/ParameterLists def self.from_yaml(manifest) return unless manifest @@ -40,7 +43,7 @@ module Gitlab nil end - def self.from_resource(resource) + def self.from_resource(resource, environment_ids = []) return unless resource return if !resource[:metadata] || !resource[:spec] @@ -54,7 +57,8 @@ module Gitlab selector: spec[:podSelector], policy_types: spec[:policyTypes], ingress: spec[:ingress], - egress: spec[:egress] + egress: spec[:egress], + environment_ids: environment_ids ) end @@ -69,7 +73,7 @@ module Gitlab private - attr_reader :name, :namespace, :labels, :creation_timestamp, :policy_types, :ingress, :egress + attr_reader :name, :namespace, :labels, :creation_timestamp, :policy_types, :ingress, :egress, :environment_ids def selector @selector ||= {} diff --git a/lib/gitlab/kubernetes/network_policy_common.rb b/lib/gitlab/kubernetes/network_policy_common.rb index 99517454508..de91833b734 100644 --- a/lib/gitlab/kubernetes/network_policy_common.rb +++ b/lib/gitlab/kubernetes/network_policy_common.rb @@ -16,7 +16,8 @@ module Gitlab creation_timestamp: creation_timestamp, manifest: manifest, is_autodevops: autodevops?, - is_enabled: enabled? + is_enabled: enabled?, + environment_ids: environment_ids } end diff --git a/lib/gitlab/path_regex.rb b/lib/gitlab/path_regex.rb index 16a6c470213..4cb47ffc6d9 100644 --- a/lib/gitlab/path_regex.rb +++ b/lib/gitlab/path_regex.rb @@ -177,7 +177,7 @@ module Gitlab end def repository_route_regex - @repository_route_regex ||= /#{full_namespace_route_regex}|#{personal_snippet_repository_path_regex}/.freeze + @repository_route_regex ||= /(#{full_namespace_route_regex}|#{personal_snippet_repository_path_regex})\.*/.freeze end def repository_git_route_regex @@ -185,7 +185,7 @@ module Gitlab end def repository_wiki_git_route_regex - @repository_wiki_git_route_regex ||= /#{full_namespace_route_regex}\.wiki\.git/.freeze + @repository_wiki_git_route_regex ||= /#{full_namespace_route_regex}\.*\.wiki\.git/.freeze end def full_namespace_path_regex diff --git a/lib/tasks/gitlab/db.rake b/lib/tasks/gitlab/db.rake index 68705a55602..963c7e486f6 100644 --- a/lib/tasks/gitlab/db.rake +++ b/lib/tasks/gitlab/db.rake @@ -90,11 +90,14 @@ namespace :gitlab do desc 'This adjusts and cleans db/structure.sql - it runs after db:structure:dump' task :clean_structure_sql do |task_name| - structure_file = 'db/structure.sql' - schema = File.read(structure_file) + ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each do |db_config| + structure_file = ActiveRecord::Tasks::DatabaseTasks.dump_filename(db_config.name) - File.open(structure_file, 'wb+') do |io| - Gitlab::Database::SchemaCleaner.new(schema).clean(io) + schema = File.read(structure_file) + + File.open(structure_file, 'wb+') do |io| + Gitlab::Database::SchemaCleaner.new(schema).clean(io) + end end # Allow this task to be called multiple times, as happens when running db:migrate:redo diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 4ee339377bf..78de74218e1 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -77,6 +77,9 @@ msgstr "" msgid " or references (e.g. path/to/project!merge_request_id)" msgstr "" +msgid " reacted with :%{name}:" +msgstr "" + msgid "\"%{path}\" did not exist on \"%{ref}\"" msgstr "" @@ -687,7 +690,7 @@ msgstr "" msgid "%{link_start}Start the title with %{draft_snippet}%{link_end} to prevent a merge request that is a work in progress from being merged before it's ready." msgstr "" -msgid "%{listToShow}, and %{awardsListLength} more." +msgid "%{listToShow}, and %{awardsListLength} more" msgstr "" msgid "%{location} is missing required keys: %{keys}" diff --git a/spec/features/issues/user_interacts_with_awards_spec.rb b/spec/features/issues/user_interacts_with_awards_spec.rb index 2921eea7641..2e52a8d862e 100644 --- a/spec/features/issues/user_interacts_with_awards_spec.rb +++ b/spec/features/issues/user_interacts_with_awards_spec.rb @@ -63,7 +63,7 @@ RSpec.describe 'User interacts with awards' do page.within('.awards') do expect(page).to have_selector('[data-testid="award-button"]') expect(page.find('[data-testid="award-button"].selected .js-counter')).to have_content('1') - expect(page).to have_css('[data-testid="award-button"].selected[title="You"]') + expect(page).to have_css('[data-testid="award-button"].selected[title="You reacted with :8ball:"]') expect do page.find('[data-testid="award-button"].selected').click diff --git a/spec/finders/environments/environments_finder_spec.rb b/spec/finders/environments/environments_finder_spec.rb index 68c0c524478..71d10ceb5d3 100644 --- a/spec/finders/environments/environments_finder_spec.rb +++ b/spec/finders/environments/environments_finder_spec.rb @@ -3,9 +3,11 @@ require 'spec_helper' RSpec.describe Environments::EnvironmentsFinder do - let(:project) { create(:project, :repository) } - let(:user) { project.creator } - let(:environment) { create(:environment, :available, project: project) } + let_it_be(:project) { create(:project, :repository) } + let_it_be(:user) { project.creator } + let_it_be(:environment) { create(:environment, :available, project: project) } + let_it_be(:environment_stopped) { create(:environment, :stopped, name: 'test2', project: project) } + let_it_be(:environment_available) { create(:environment, :available, name: 'test3', project: project) } before do project.add_maintainer(user) @@ -13,18 +15,18 @@ RSpec.describe Environments::EnvironmentsFinder do describe '#execute' do context 'with states parameter' do - let(:stopped_environment) { create(:environment, :stopped, project: project) } + let_it_be(:stopped_environment) { create(:environment, :stopped, project: project) } it 'returns environments with the requested state' do result = described_class.new(project, user, states: 'available').execute - expect(result).to contain_exactly(environment) + expect(result).to contain_exactly(environment, environment_available) end it 'returns environments with any of the requested states' do result = described_class.new(project, user, states: %w(available stopped)).execute - expect(result).to contain_exactly(environment, stopped_environment) + expect(result).to contain_exactly(environment, environment_stopped, environment_available, stopped_environment) end it 'raises exception when requested state is invalid' do @@ -37,25 +39,30 @@ RSpec.describe Environments::EnvironmentsFinder do it 'returns environments with the requested state' do result = described_class.new(project, user, states: :available).execute - expect(result).to contain_exactly(environment) + expect(result).to contain_exactly(environment, environment_available) end it 'returns environments with any of the requested states' do result = described_class.new(project, user, states: [:available, :stopped]).execute - expect(result).to contain_exactly(environment, stopped_environment) + expect(result).to contain_exactly(environment, environment_stopped, environment_available, stopped_environment) end end end context 'with search and states' do - let(:environment2) { create(:environment, :stopped, name: 'test2', project: project) } - let(:environment3) { create(:environment, :available, name: 'test3', project: project) } - it 'searches environments by name and state' do result = described_class.new(project, user, search: 'test', states: :available).execute - expect(result).to contain_exactly(environment3) + expect(result).to contain_exactly(environment_available) + end + end + + context 'with id' do + it 'searches environments by name and state' do + result = described_class.new(project, user, search: 'test', environment_ids: [environment_available.id]).execute + + expect(result).to contain_exactly(environment_available) end end end diff --git a/spec/fixtures/gitlab/database/structure_example_cleaned.sql b/spec/fixtures/gitlab/database/structure_example_cleaned.sql index dc112da7037..ab6af34dda7 100644 --- a/spec/fixtures/gitlab/database/structure_example_cleaned.sql +++ b/spec/fixtures/gitlab/database/structure_example_cleaned.sql @@ -23,6 +23,4 @@ ALTER TABLE ONLY abuse_reports ALTER COLUMN id SET DEFAULT nextval('abuse_report ALTER TABLE ONLY abuse_reports ADD CONSTRAINT abuse_reports_pkey PRIMARY KEY (id); -CREATE INDEX index_abuse_reports_on_user_id ON abuse_reports USING btree (user_id);-- schema_migrations.version information is no longer stored in this file, --- but instead tracked in the db/schema_migrations directory --- see https://gitlab.com/gitlab-org/gitlab/-/issues/218590 for details +CREATE INDEX index_abuse_reports_on_user_id ON abuse_reports USING btree (user_id); diff --git a/spec/frontend/vue_shared/components/__snapshots__/awards_list_spec.js.snap b/spec/frontend/vue_shared/components/__snapshots__/awards_list_spec.js.snap index 3f91591f5cd..c14cf0db370 100644 --- a/spec/frontend/vue_shared/components/__snapshots__/awards_list_spec.js.snap +++ b/spec/frontend/vue_shared/components/__snapshots__/awards_list_spec.js.snap @@ -7,7 +7,7 @@ exports[`vue_shared/components/awards_list default matches snapshot 1`] = `