diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-11 15:08:52 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-11 15:08:52 +0300 |
commit | 9f5ac379c76c278ee9ee1662e26c4612b0a117bd (patch) | |
tree | 49cd59544c083678fefd1e77340ca5e2b6e3565c /db | |
parent | 7240fb1a06c9e1b254719426b1ac96ec2f00fe35 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r-- | db/fixtures/development/30_composer_packages.rb | 121 | ||||
-rw-r--r-- | db/migrate/20210210210232_add_notes_create_limit_allowlist_to_application_settings.rb | 9 | ||||
-rw-r--r-- | db/schema_migrations/20210210210232 | 1 | ||||
-rw-r--r-- | db/structure.sql | 1 |
4 files changed, 132 insertions, 0 deletions
diff --git a/db/fixtures/development/30_composer_packages.rb b/db/fixtures/development/30_composer_packages.rb new file mode 100644 index 00000000000..fa8c648de9e --- /dev/null +++ b/db/fixtures/development/30_composer_packages.rb @@ -0,0 +1,121 @@ +# frozen_string_literal: true + +require './spec/support/sidekiq_middleware' + +class Gitlab::Seeder::ComposerPackages + def group + @group ||= Group.find_by(path: 'composer') + + unless @group + @group = Group.create!( + name: 'Composer', + path: 'composer', + description: FFaker::Lorem.sentence + ) + + @group.add_owner(user) + @group.create_namespace_settings + end + + @group + end + + def user + @user ||= User.first + end + + def create_real_project!(url) + project_path = url.split('/').last + + project_path.gsub!(".git", "") + + project = group.projects.find_by(name: project_path.titleize) + + return project if project.present? + + params = { + import_url: url, + namespace_id: group.id, + name: project_path.titleize, + description: FFaker::Lorem.sentence, + visibility_level: Gitlab::VisibilityLevel.values.sample, + skip_disk_validation: true + } + + Sidekiq::Worker.skipping_transaction_check do + project = ::Projects::CreateService.new(user, params).execute + + # Seed-Fu runs this entire fixture in a transaction, so the `after_commit` + # hook won't run until after the fixture is loaded. That is too late + # since the Sidekiq::Testing block has already exited. Force clearing + # the `after_commit` queue to ensure the job is run now. + project.send(:_run_after_commit_queue) + project.import_state.send(:_run_after_commit_queue) + + # Expire repository cache after import to ensure + # valid_repo? call below returns a correct answer + project.repository.expire_all_method_caches + end + + if project.valid? && project.valid_repo? + print '.' + return project + else + puts project.errors.full_messages + print 'F' + return nil + end + end +end + +COMPOSER_PACKAGES = { + 'https://github.com/php-fig/log.git' => [ + { branch: 'master' }, + { tag: 'v1.5.2' } + ], + 'https://github.com/ryssbowh/craft-themes.git' => [ + { tag: '1.0.2' } + ], + 'https://github.com/php-fig/http-message.git' => [ + { tag: '1.0.1' } + ], + 'https://github.com/doctrine/instantiator.git' => [ + { branch: '1.4.x' } + ] +}.freeze + +Gitlab::Seeder.quiet do + flag = 'SEED_COMPOSER' + + unless ENV[flag] + puts "Use the `#{flag}` environment variable to seed composer packages" + next + end + + Sidekiq::Testing.inline! do + COMPOSER_PACKAGES.each do |path, versions| + project = Gitlab::Seeder::ComposerPackages.new.create_real_project!(path) + + versions.each do |version| + params = {} + + if version[:branch] + params[:branch] = project.repository.find_branch(version[:branch]) + elsif version[:tag] + params[:tag] = project.repository.find_tag(version[:tag]) + end + + if params[:branch].nil? && params[:tag].nil? + puts "version #{version.inspect} not found" + next + end + + ::Packages::Composer::CreatePackageService + .new(project, project.owner, params) + .execute + + puts "version #{version.inspect} created!" + end + end + end +end diff --git a/db/migrate/20210210210232_add_notes_create_limit_allowlist_to_application_settings.rb b/db/migrate/20210210210232_add_notes_create_limit_allowlist_to_application_settings.rb new file mode 100644 index 00000000000..56feed3688c --- /dev/null +++ b/db/migrate/20210210210232_add_notes_create_limit_allowlist_to_application_settings.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddNotesCreateLimitAllowlistToApplicationSettings < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def change + add_column :application_settings, :notes_create_limit_allowlist, :text, array: true, default: [], null: false + end +end diff --git a/db/schema_migrations/20210210210232 b/db/schema_migrations/20210210210232 new file mode 100644 index 00000000000..96f31a2adef --- /dev/null +++ b/db/schema_migrations/20210210210232 @@ -0,0 +1 @@ +e1bd58eeaf63caf473680a8c4b7269cc63e7c0d6e8d4e71636608e10c9731c85
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 487b0728ccb..5c1791e6264 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -9414,6 +9414,7 @@ CREATE TABLE application_settings ( asset_proxy_allowlist text, keep_latest_artifact boolean DEFAULT true NOT NULL, notes_create_limit integer DEFAULT 300 NOT NULL, + notes_create_limit_allowlist text[] DEFAULT '{}'::text[] NOT NULL, CONSTRAINT app_settings_container_reg_cleanup_tags_max_list_size_positive CHECK ((container_registry_cleanup_tags_service_max_list_size >= 0)), CONSTRAINT app_settings_registry_exp_policies_worker_capacity_positive CHECK ((container_registry_expiration_policies_worker_capacity >= 0)), CONSTRAINT check_17d9558205 CHECK ((char_length((kroki_url)::text) <= 1024)), |