Commit 1383abb6 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'vij-snippet-fixtures' into 'master'

Stop Snippet fixtures from repeatedly cloning

See merge request gitlab-org/gitlab!46480
parents 36214a5a bf5338ce
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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment