Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/ruby
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2021-11-18 14:05:18 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-11-30 15:24:45 +0300
commita818370993ae6fe9785b5116dac23611eb9361f9 (patch)
tree66e74892c586cb36e893581ce49783ed7e5fc89b /ruby
parent60d1b61f3afc26a7f17d9a0c90567ea03addf293 (diff)
git: Implement support for bundled Git binaries
Now that we can build bundled Git binaries, this commit introduces support into the Git command factory to support them. If a new option "git.use_bundled_binaries" is set to `true`, then we automatically derive the Git binary's path from the binary directory of Gitaly. Note that we must go through some hoops though given that the bundled binaries have a "gitaly-" prefix. While it's not much of a problem when executing Git directly, some Git commands require it to find auxiliary helper binaries like "git-remote-http" or "git-receive-pack". To support these cases, we thus create a temporary directory and symlink all binaries Git expects to be present into it. By pointing GIT_EXEC_PATH at this directory, we can thus trick Git into picking the correct set of binaries. This new bundled mode will required configuration changes by admins.
Diffstat (limited to 'ruby')
-rw-r--r--ruby/spec/test_repo_helper.rb22
1 files changed, 20 insertions, 2 deletions
diff --git a/ruby/spec/test_repo_helper.rb b/ruby/spec/test_repo_helper.rb
index 603de4d08..91f46dc30 100644
--- a/ruby/spec/test_repo_helper.rb
+++ b/ruby/spec/test_repo_helper.rb
@@ -6,7 +6,22 @@ require 'spec_helper'
$:.unshift(File.expand_path('../proto', __dir__))
require 'gitaly'
-Gitlab.config.git.test_global_ivar_override(:bin_path, ENV.fetch('GITALY_TESTING_GIT_BINARY', 'git'))
+if ENV.key?('GITALY_TESTING_GIT_BINARY')
+ GIT_BINARY_PATH = ENV['GITALY_TESTING_GIT_BINARY']
+elsif ENV.key?('GITALY_TESTING_BUNDLED_GIT_PATH')
+ GIT_BINARY_PATH = File.join(ENV['GITALY_TESTING_BUNDLED_GIT_PATH'], 'gitaly-git')
+ GIT_EXEC_PATH = File.join(TMP_DIR, 'git-exec-path')
+
+ # We execute git-clone(1) to set up the test repo, and this requires Git to
+ # find git-upload-pack(1). We thus symlink it into a temporary Git exec path
+ # and make it known to Git where it lives.
+ Dir.mkdir(GIT_EXEC_PATH)
+ File.symlink(GIT_BINARY_PATH, File.join(GIT_EXEC_PATH, 'git-upload-pack'))
+else
+ GIT_BINARY_PATH = 'git'.freeze
+end
+
+Gitlab.config.git.test_global_ivar_override(:bin_path, GIT_BINARY_PATH)
Gitlab.config.git.test_global_ivar_override(:hooks_directory, File.join(GITALY_RUBY_DIR, "hooks"))
Gitlab.config.gitaly.test_global_ivar_override(:bin_dir, __dir__)
@@ -97,7 +112,10 @@ module TestRepo
end
def self.clone_new_repo!(origin, destination)
- return if system(Gitlab.config.git.bin_path, "-c", "init.templateDir=", "clone", "--quiet", "--bare", origin.to_s, destination.to_s)
+ env = {}
+ env['GIT_EXEC_PATH'] = GIT_EXEC_PATH if defined?(GIT_EXEC_PATH)
+
+ return if system(env, Gitlab.config.git.bin_path, "-c", "init.templateDir=", "clone", "--quiet", "--bare", origin.to_s, destination.to_s)
abort "Failed to clone test repo. Try running 'make prepare-tests' and try again."
end