summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2017-05-03 17:45:33 +0200
committerRémy Coutable <remy@rymai.me>2017-05-04 17:19:56 +0200
commit59eed53f8c2eafac09f80a66bc1987d8731a74a7 (patch)
tree13939462fa54d6b205dc71f63afbfc1b658d5e31
parente7b6f39fe1b3d6d21c32f564a3efe17c1c34fd74 (diff)
downloadgitlab-ce-31562-fix-test_env-set_repo_refs.tar.gz
Clone test repo as bare repo for project factories with repo31562-fix-test_env-set_repo_refs
Instead of bare cloning in TestEnv#init, we now perform these clones in TestEnv#copy_repo directly. This ensures the refs are up-to-date. Signed-off-by: Rémy Coutable <remy@rymai.me>
-rw-r--r--spec/javascripts/fixtures/projects.rb4
-rw-r--r--spec/support/test_env.rb52
2 files changed, 23 insertions, 33 deletions
diff --git a/spec/javascripts/fixtures/projects.rb b/spec/javascripts/fixtures/projects.rb
index 6c33b240e5c..3acc8fd9975 100644
--- a/spec/javascripts/fixtures/projects.rb
+++ b/spec/javascripts/fixtures/projects.rb
@@ -4,8 +4,8 @@ describe ProjectsController, '(JavaScript fixtures)', type: :controller do
include JavaScriptFixturesHelpers
let(:admin) { create(:admin) }
- let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
- let(:project) { create(:project, namespace: namespace, path: 'builds-project') }
+ let(:namespace) { create(:namespace, name: 'frontend-fixtures' ) }
+ let(:project) { create(:project, :repository, namespace: namespace, path: 'projects-project') }
render_views
diff --git a/spec/support/test_env.rb b/spec/support/test_env.rb
index 0b3c6169c9b..885b8ca314b 100644
--- a/spec/support/test_env.rb
+++ b/spec/support/test_env.rb
@@ -39,8 +39,8 @@ module TestEnv
'wip' => 'b9238ee',
'csv' => '3dd0896',
'v1.1.0' => 'b83d6e3',
- 'add-ipython-files' => '6d85bb69',
- 'add-pdf-file' => 'e774ebd3'
+ 'add-ipython-files' => '6d85bb6',
+ 'add-pdf-file' => 'e774ebd'
}.freeze
# gitlab-test-fork is a fork of gitlab-fork, but we don't necessarily
@@ -100,7 +100,7 @@ module TestEnv
tmp_test_path = Rails.root.join('tmp', 'tests', '**')
Dir[tmp_test_path].each do |entry|
- unless File.basename(entry) =~ /\A(gitaly|gitlab-(shell|test|test_bare|test-fork|test-fork_bare))\z/
+ unless File.basename(entry) =~ /\A(gitaly|gitlab-(shell|test|test-fork))\z/
FileUtils.rm_rf(entry)
end
end
@@ -142,38 +142,33 @@ module TestEnv
end
def setup_factory_repo
- setup_repo(factory_repo_path, factory_repo_path_bare, factory_repo_name,
- BRANCH_SHA)
+ setup_repo(factory_repo_path, factory_repo_name, BRANCH_SHA)
end
# This repo has a submodule commit that is not present in the main test
# repository.
def setup_forked_repo
- setup_repo(forked_repo_path, forked_repo_path_bare, forked_repo_name,
- FORKED_BRANCH_SHA)
+ setup_repo(forked_repo_path, forked_repo_name, FORKED_BRANCH_SHA)
end
- def setup_repo(repo_path, repo_path_bare, repo_name, branch_sha)
+ def setup_repo(repo_path, repo_name, branch_sha)
clone_url = "https://gitlab.com/gitlab-org/#{repo_name}.git"
unless File.directory?(repo_path)
system(*%W(#{Gitlab.config.git.bin_path} clone -q #{clone_url} #{repo_path}))
end
-
set_repo_refs(repo_path, branch_sha)
+ end
+
+ def copy_repo(project)
+ target_repo_path = File.expand_path("#{project.repository_storage_path}/#{project.full_path}.git")
- unless File.directory?(repo_path_bare)
+ unless File.directory?(target_repo_path)
# We must copy bare repositories because we will push to them.
- system(git_env, *%W(#{Gitlab.config.git.bin_path} clone -q --bare #{repo_path} #{repo_path_bare}))
+ system(git_env, *%W(#{Gitlab.config.git.bin_path} clone -q --bare #{factory_repo_path} #{target_repo_path}))
+ FileUtils.chmod_R(0755, target_repo_path)
end
- end
- def copy_repo(project)
- base_repo_path = File.expand_path(factory_repo_path_bare)
- target_repo_path = File.expand_path(project.repository_storage_path + "/#{project.full_path}.git")
- FileUtils.mkdir_p(target_repo_path)
- FileUtils.cp_r("#{base_repo_path}/.", target_repo_path)
- FileUtils.chmod_R 0755, target_repo_path
set_repo_refs(target_repo_path, BRANCH_SHA)
end
@@ -190,11 +185,14 @@ module TestEnv
end
def copy_forked_repo_with_submodules(project)
- base_repo_path = File.expand_path(forked_repo_path_bare)
- target_repo_path = File.expand_path(project.repository_storage_path + "/#{project.full_path}.git")
- FileUtils.mkdir_p(target_repo_path)
- FileUtils.cp_r("#{base_repo_path}/.", target_repo_path)
- FileUtils.chmod_R 0755, target_repo_path
+ target_repo_path = File.expand_path("#{project.repository_storage_path}/#{project.full_path}.git")
+
+ unless File.directory?(target_repo_path)
+ # We must copy bare repositories because we will push to them.
+ system(git_env, *%W(#{Gitlab.config.git.bin_path} clone -q --bare #{forked_repo_path} #{target_repo_path}))
+ FileUtils.chmod_R(0755, target_repo_path)
+ end
+
set_repo_refs(target_repo_path, FORKED_BRANCH_SHA)
end
@@ -215,10 +213,6 @@ module TestEnv
@factory_repo_path ||= Rails.root.join('tmp', 'tests', factory_repo_name)
end
- def factory_repo_path_bare
- "#{factory_repo_path}_bare"
- end
-
def factory_repo_name
'gitlab-test'
end
@@ -227,10 +221,6 @@ module TestEnv
@forked_repo_path ||= Rails.root.join('tmp', 'tests', forked_repo_name)
end
- def forked_repo_path_bare
- "#{forked_repo_path}_bare"
- end
-
def forked_repo_name
'gitlab-test-fork'
end