diff options
-rwxr-xr-x | hooks/pre-receive | 4 | ||||
-rw-r--r-- | lib/gitlab_shell.rb | 3 | ||||
-rw-r--r-- | spec/gitlab_shell_spec.rb | 2 |
3 files changed, 4 insertions, 5 deletions
diff --git a/hooks/pre-receive b/hooks/pre-receive index 6ed9a2c..a7eeb30 100755 --- a/hooks/pre-receive +++ b/hooks/pre-receive @@ -5,14 +5,12 @@ refs = $stdin.read key_id = ENV['GL_ID'] -protocol = ENV['PROTOCOL'] +protocol = ENV['PROTOCOL'] || 'http' repo_path = Dir.pwd require_relative '../lib/gitlab_custom_hook' require_relative '../lib/gitlab_access' -protocol ||= 'http' - if GitlabAccess.new(repo_path, key_id, refs, protocol).exec && GitlabCustomHook.new.pre_receive(refs, repo_path) exit 0 diff --git a/lib/gitlab_shell.rb b/lib/gitlab_shell.rb index 2bb8a4d..3dc10b6 100644 --- a/lib/gitlab_shell.rb +++ b/lib/gitlab_shell.rb @@ -131,7 +131,8 @@ class GitlabShell 'PATH' => ENV['PATH'], 'LD_LIBRARY_PATH' => ENV['LD_LIBRARY_PATH'], 'LANG' => ENV['LANG'], - 'GL_ID' => @key_id + 'GL_ID' => @key_id, + 'PROTOCOL' => 'ssh' } if @config.git_annex_enabled? diff --git a/spec/gitlab_shell_spec.rb b/spec/gitlab_shell_spec.rb index 79fa49b..0b0a817 100644 --- a/spec/gitlab_shell_spec.rb +++ b/spec/gitlab_shell_spec.rb @@ -242,7 +242,7 @@ describe GitlabShell do after { subject.exec(ssh_cmd) } it "should call api.check_access" do - api.should_receive(:check_access).with('git-upload-pack', 'gitlab-ci.git', key_id, '_any') + api.should_receive(:check_access).with('git-upload-pack', 'gitlab-ci.git', key_id, '_any', 'ssh') end it "should disallow access and log the attempt if check_access returns false status" do |