diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-17 09:09:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-17 09:09:11 +0300 |
commit | 6110935892876a26d8dfcb919d8c955c92ecc1e5 (patch) | |
tree | 09c4393c8eb9d3807df842d6d707fb319ffbd7ea /spec/support/helpers/test_env.rb | |
parent | 4bc0e064023a13d90da5acc4fd152fca66926ea2 (diff) |
Add latest changes from gitlab-org/gitlab@master
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? |