diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-05-23 15:41:34 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2017-05-23 15:41:34 +0000 |
commit | db96f7244f52842798e2fb4261677838d2766162 (patch) | |
tree | 900bf1023803d32a3ee67356848e3e3ebad1434f /lib/gitlab_shell.rb | |
parent | 285c061ed8933c0d94a9ad027f99653039673324 (diff) | |
parent | f3b83553d67058003819fb844c8a1cde1da5c9af (diff) | |
download | gitlab-shell-db96f7244f52842798e2fb4261677838d2766162.tar.gz |
Merge branch 'go-wrappers' into 'master'
Use gitaly-upload-pack and gitaly-receive-pack
Closes gitaly#193
See merge request !129
Diffstat (limited to 'lib/gitlab_shell.rb')
-rw-r--r-- | lib/gitlab_shell.rb | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/lib/gitlab_shell.rb b/lib/gitlab_shell.rb index 355d493..e7d0254 100644 --- a/lib/gitlab_shell.rb +++ b/lib/gitlab_shell.rb @@ -10,6 +10,10 @@ class GitlabShell class InvalidRepositoryPathError < StandardError; end GIT_COMMANDS = %w(git-upload-pack git-receive-pack git-upload-archive git-lfs-authenticate).freeze + GITALY_MIGRATED_COMMANDS = { + 'git-upload-pack' => File.join(ROOT_PATH, 'bin', 'gitaly-upload-pack'), + 'git-receive-pack' => File.join(ROOT_PATH, 'bin', 'gitaly-receive-pack'), + } API_COMMANDS = %w(2fa_recovery_codes) GL_PROTOCOL = 'ssh'.freeze @@ -105,10 +109,30 @@ class GitlabShell $logger.info "gitlab-shell: Processing LFS authentication for #{log_username}." lfs_authenticate end - else - $logger.info "gitlab-shell: executing git command <#{@command} #{repo_path}> for #{log_username}." - exec_cmd(@command, repo_path) + return + end + + executable = @command + args = [repo_path] + + if GITALY_MIGRATED_COMMANDS.has_key?(executable) + executable = GITALY_MIGRATED_COMMANDS[executable] + + gitaly_address = '' # would be returned by gitlab-rails internal API + + # The entire gitaly_request hash should be built in gitlab-ce and passed + # on as-is. For now we build a fake one on the spot. + gitaly_request = JSON.dump({ + 'repository' => { 'path' => repo_path }, + 'gl_id' => @key_id, + }) + + args = [gitaly_address, gitaly_request] end + + args_string = [File.basename(executable), *args].join(' ') + $logger.info "gitlab-shell: executing git command <#{args_string}> for #{log_username}." + exec_cmd(executable, *args) end # This method is not covered by Rspec because it ends the current Ruby process. @@ -138,7 +162,8 @@ class GitlabShell }) end - Kernel::exec(env, *args, unsetenv_others: true) + # We use 'chdir: ROOT_PATH' to let the next executable know where config.yml is. + Kernel::exec(env, *args, unsetenv_others: true, chdir: ROOT_PATH) end def api |