diff options
Diffstat (limited to 'db/fixtures/development')
-rw-r--r-- | db/fixtures/development/02_application_settings.rb | 3 | ||||
-rw-r--r-- | db/fixtures/development/12_snippets.rb | 26 |
2 files changed, 28 insertions, 1 deletions
diff --git a/db/fixtures/development/02_application_settings.rb b/db/fixtures/development/02_application_settings.rb index 67486d2ab5f..46da3205d8f 100644 --- a/db/fixtures/development/02_application_settings.rb +++ b/db/fixtures/development/02_application_settings.rb @@ -7,4 +7,7 @@ ApplicationSetting.create_from_defaults puts "Enable hashed storage for every new projects.".color(:green) ApplicationSetting.current_without_cache.update!(hashed_storage_enabled: true) +puts "Generate CI JWT signing key".color(:green) +ApplicationSetting.current_without_cache.update!(ci_jwt_signing_key: OpenSSL::PKey::RSA.new(2048).to_pem) + print '.' diff --git a/db/fixtures/development/12_snippets.rb b/db/fixtures/development/12_snippets.rb index 8ceabcdcd9b..6d31007b320 100644 --- a/db/fixtures/development/12_snippets.rb +++ b/db/fixtures/development/12_snippets.rb @@ -1,6 +1,28 @@ require './spec/support/sidekiq_middleware' SNIPPET_REPO_URL = "https://gitlab.com/gitlab-org/gitlab-snippet-test.git" +BUNDLE_PATH = File.join(Rails.root, 'db/fixtures/development/gitlab-snippet-test.bundle') + +class Gitlab::Seeder::SnippetRepository + def initialize(snippet) + @snippet = snippet + end + + def import + if File.exists?(BUNDLE_PATH) + @snippet.repository.create_from_bundle(BUNDLE_PATH) + else + @snippet.repository.import_repository(SNIPPET_REPO_URL) + @snippet.repository.bundle_to_disk(BUNDLE_PATH) + end + end + + def self.cleanup + File.delete(BUNDLE_PATH) if File.exists?(BUNDLE_PATH) + rescue => e + warn "\nError cleaning up snippet bundle: #{e}" + end +end Gitlab::Seeder.quiet do 20.times do |i| @@ -14,7 +36,7 @@ Gitlab::Seeder.quiet do content: 'foo' }).tap do |snippet| unless snippet.repository_exists? - snippet.repository.import_repository(SNIPPET_REPO_URL) + Gitlab::Seeder::SnippetRepository.new(snippet).import end snippet.track_snippet_repository(snippet.repository.storage) @@ -23,5 +45,7 @@ Gitlab::Seeder.quiet do print('.') end + + Gitlab::Seeder::SnippetRepository.cleanup end |