2018-12-13 13:39:08 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
require_relative 'test_env'
|
|
|
|
|
|
|
|
# This file is specific to specs in spec/lib/gitlab/git/
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
SEED_STORAGE_PATH = Gitlab::GitalyClient::StorageSettings.allow_disk_access { TestEnv.repos_path }
|
2018-12-13 13:39:08 +05:30
|
|
|
TEST_REPO_PATH = 'gitlab-git-test.git'
|
|
|
|
TEST_NORMAL_REPO_PATH = 'not-bare-repo.git'
|
|
|
|
TEST_MUTABLE_REPO_PATH = 'mutable-repo.git'
|
|
|
|
TEST_BROKEN_REPO_PATH = 'broken-repo.git'
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
module SeedHelper
|
2018-12-13 13:39:08 +05:30
|
|
|
GITLAB_GIT_TEST_REPO_URL = File.expand_path('../gitlab-git-test.git', __dir__)
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
def ensure_seeds
|
|
|
|
if File.exist?(SEED_STORAGE_PATH)
|
|
|
|
FileUtils.rm_r(SEED_STORAGE_PATH)
|
|
|
|
end
|
|
|
|
|
|
|
|
FileUtils.mkdir_p(SEED_STORAGE_PATH)
|
|
|
|
|
|
|
|
create_bare_seeds
|
|
|
|
create_normal_seeds
|
|
|
|
create_mutable_seeds
|
|
|
|
create_broken_seeds
|
|
|
|
end
|
|
|
|
|
|
|
|
def create_bare_seeds
|
|
|
|
system(git_env, *%W(#{Gitlab.config.git.bin_path} clone --bare #{GITLAB_GIT_TEST_REPO_URL}),
|
|
|
|
chdir: SEED_STORAGE_PATH,
|
|
|
|
out: '/dev/null',
|
|
|
|
err: '/dev/null')
|
|
|
|
end
|
|
|
|
|
|
|
|
def create_normal_seeds
|
|
|
|
system(git_env, *%W(#{Gitlab.config.git.bin_path} clone #{TEST_REPO_PATH} #{TEST_NORMAL_REPO_PATH}),
|
|
|
|
chdir: SEED_STORAGE_PATH,
|
|
|
|
out: '/dev/null',
|
|
|
|
err: '/dev/null')
|
|
|
|
end
|
|
|
|
|
|
|
|
def create_mutable_seeds
|
2018-03-17 18:26:18 +05:30
|
|
|
system(git_env, *%W(#{Gitlab.config.git.bin_path} clone --bare #{TEST_REPO_PATH} #{TEST_MUTABLE_REPO_PATH}),
|
2017-08-17 22:00:37 +05:30
|
|
|
chdir: SEED_STORAGE_PATH,
|
|
|
|
out: '/dev/null',
|
|
|
|
err: '/dev/null')
|
|
|
|
|
|
|
|
mutable_repo_full_path = File.join(SEED_STORAGE_PATH, TEST_MUTABLE_REPO_PATH)
|
|
|
|
system(git_env, *%W(#{Gitlab.config.git.bin_path} branch -t feature origin/feature),
|
|
|
|
chdir: mutable_repo_full_path, out: '/dev/null', err: '/dev/null')
|
|
|
|
|
|
|
|
system(git_env, *%W(#{Gitlab.config.git.bin_path} remote add expendable #{GITLAB_GIT_TEST_REPO_URL}),
|
|
|
|
chdir: mutable_repo_full_path, out: '/dev/null', err: '/dev/null')
|
|
|
|
end
|
|
|
|
|
|
|
|
def create_broken_seeds
|
|
|
|
system(git_env, *%W(#{Gitlab.config.git.bin_path} clone --bare #{TEST_REPO_PATH} #{TEST_BROKEN_REPO_PATH}),
|
|
|
|
chdir: SEED_STORAGE_PATH,
|
|
|
|
out: '/dev/null',
|
|
|
|
err: '/dev/null')
|
|
|
|
|
|
|
|
refs_path = File.join(SEED_STORAGE_PATH, TEST_BROKEN_REPO_PATH, 'refs')
|
|
|
|
|
|
|
|
FileUtils.rm_r(refs_path)
|
|
|
|
end
|
|
|
|
end
|