diff options
author | Jacob Vosmaer <jacob@gitlab.com> | 2017-05-04 11:06:13 +0200 |
---|---|---|
committer | Jacob Vosmaer <jacob@gitlab.com> | 2017-05-23 15:26:35 +0200 |
commit | f3b83553d67058003819fb844c8a1cde1da5c9af (patch) | |
tree | 900bf1023803d32a3ee67356848e3e3ebad1434f | |
parent | 2a163a1754fd22573470e81ecd9727bbe96c43ba (diff) | |
download | gitlab-shell-go-wrappers.tar.gz |
Make gitaly executable mapping clearergo-wrappers
-rw-r--r-- | lib/gitlab_shell.rb | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/gitlab_shell.rb b/lib/gitlab_shell.rb index d905bd7..e7d0254 100644 --- a/lib/gitlab_shell.rb +++ b/lib/gitlab_shell.rb @@ -10,7 +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 = %w(git-upload-pack git-receive-pack) + 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 @@ -109,26 +112,27 @@ class GitlabShell return end - args = [@command, repo_path] + executable = @command + args = [repo_path] - if GITALY_MIGRATED_COMMANDS.include?(args[0]) - executable = args[0].sub('git', File.join(ROOT_PATH, 'bin/gitaly')) + 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' => args[1] }, + 'repository' => { 'path' => repo_path }, 'gl_id' => @key_id, }) - args = [executable, gitaly_address, gitaly_request] + args = [gitaly_address, gitaly_request] end - args_string = [File.basename(args[0]), *args[1, args.length]].join(' ') + args_string = [File.basename(executable), *args].join(' ') $logger.info "gitlab-shell: executing git command <#{args_string}> for #{log_username}." - exec_cmd(*args) + exec_cmd(executable, *args) end # This method is not covered by Rspec because it ends the current Ruby process. |