Commit fd41b8a4 authored by Patricio Cano's avatar Patricio Cano

Simplify protocol assign, and populate ENV['PROTOCOL'] variable when calling hooks via SSH

parent 1c18095c
......@@ -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
......
......@@ -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?
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment