diff options
Diffstat (limited to 'spec/support/helpers/test_env.rb')
-rw-r--r-- | spec/support/helpers/test_env.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/support/helpers/test_env.rb b/spec/support/helpers/test_env.rb index 09d16f306fd..f787aedf7aa 100644 --- a/spec/support/helpers/test_env.rb +++ b/spec/support/helpers/test_env.rb @@ -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? |