Disable hooks by setting an ENV var

Prior to this change, the hooks directory got cleared. That works, but
is not the way to go about it as there's a better way. Setting the env
var this commits sets.
This commit is contained in:
Zeger-Jan van de Weg 2019-06-06 12:05:11 +02:00
parent ccdd66d035
commit 679ac7f78e
No known key found for this signature in database
GPG key ID: 65F6A8D64A88ABAC
2 changed files with 4 additions and 15 deletions

View file

@ -23,7 +23,10 @@ module GitalyTest
'BUNDLE_FLAGS' => "--jobs=4 --retry=3", 'BUNDLE_FLAGS' => "--jobs=4 --retry=3",
'BUNDLE_INSTALL_FLAGS' => nil, 'BUNDLE_INSTALL_FLAGS' => nil,
'BUNDLE_GEMFILE' => gemfile, 'BUNDLE_GEMFILE' => gemfile,
'RUBYOPT' => nil 'RUBYOPT' => nil,
# Git hooks can't run during tests as the internal API is not running.
'GITALY_TESTING_NO_GIT_HOOKS' => "1"
} }
if ENV['CI'] if ENV['CI']

View file

@ -146,19 +146,6 @@ module TestEnv
install_dir: Gitlab.config.gitlab_shell.path, install_dir: Gitlab.config.gitlab_shell.path,
version: Gitlab::Shell.version_required, version: Gitlab::Shell.version_required,
task: 'gitlab:shell:install') task: 'gitlab:shell:install')
# gitlab-shell hooks don't work in our test environment because they try to make internal API calls
sabotage_gitlab_shell_hooks
end
def sabotage_gitlab_shell_hooks
create_fake_git_hooks(Gitlab::Shell.new.hooks_path)
end
def create_fake_git_hooks(hooks_dir)
%w[pre-receive post-receive update].each do |hook|
File.open(File.join(hooks_dir, hook), 'w', 0755) { |f| f.puts '#!/bin/sh' }
end
end end
def setup_gitaly def setup_gitaly
@ -172,7 +159,6 @@ module TestEnv
task: "gitlab:gitaly:install[#{install_gitaly_args}]") do task: "gitlab:gitaly:install[#{install_gitaly_args}]") do
Gitlab::SetupHelper.create_gitaly_configuration(gitaly_dir, { 'default' => repos_path }, force: true) Gitlab::SetupHelper.create_gitaly_configuration(gitaly_dir, { 'default' => repos_path }, force: true)
create_fake_git_hooks(File.join(gitaly_dir, 'ruby/git-hooks'))
start_gitaly(gitaly_dir) start_gitaly(gitaly_dir)
end end
end end