Commit ae4b07f7 authored by Stan Hu's avatar Stan Hu

Merge branch 'fix_setup_env_for_sha_based_gitaly' into 'master'

Fix gitaly setup running always for specs setup

Closes #229736

See merge request gitlab-org/gitlab!37163
parents e589e8bd cc17af1f
......@@ -6,6 +6,8 @@ module TestEnv
ComponentFailedToInstallError = Class.new(StandardError)
SHA_REGEX = /\A[0-9a-f]{5,40}\z/i.freeze
# When developing the seed repository, comment out the branch you will modify.
BRANCH_SHA = {
'signed-commits' => '6101e87',
......@@ -508,6 +510,8 @@ module TestEnv
# Allow local overrides of the component for tests during development
return false if Rails.env.test? && File.symlink?(component_folder)
return false if component_matches_git_sha?(component_folder, expected_version)
version = File.read(File.join(component_folder, 'VERSION')).strip
# Notice that this will always yield true when using branch versions
......@@ -517,6 +521,16 @@ module TestEnv
rescue Errno::ENOENT
true
end
def component_matches_git_sha?(component_folder, expected_version)
# Not a git SHA, so return early
return false unless expected_version =~ SHA_REGEX
sha, exit_status = Gitlab::Popen.popen(%W(#{Gitlab.config.git.bin_path} rev-parse HEAD), component_folder)
return false if exit_status != 0
expected_version == sha.chomp
end
end
require_relative('../../../ee/spec/support/helpers/ee/test_env') if Gitlab.ee?
......
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