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 @@ ...@@ -5,14 +5,12 @@
refs = $stdin.read refs = $stdin.read
key_id = ENV['GL_ID'] key_id = ENV['GL_ID']
protocol = ENV['PROTOCOL'] protocol = ENV['PROTOCOL'] || 'http'
repo_path = Dir.pwd repo_path = Dir.pwd
require_relative '../lib/gitlab_custom_hook' require_relative '../lib/gitlab_custom_hook'
require_relative '../lib/gitlab_access' require_relative '../lib/gitlab_access'
protocol ||= 'http'
if GitlabAccess.new(repo_path, key_id, refs, protocol).exec && if GitlabAccess.new(repo_path, key_id, refs, protocol).exec &&
GitlabCustomHook.new.pre_receive(refs, repo_path) GitlabCustomHook.new.pre_receive(refs, repo_path)
exit 0 exit 0
......
...@@ -131,7 +131,8 @@ class GitlabShell ...@@ -131,7 +131,8 @@ class GitlabShell
'PATH' => ENV['PATH'], 'PATH' => ENV['PATH'],
'LD_LIBRARY_PATH' => ENV['LD_LIBRARY_PATH'], 'LD_LIBRARY_PATH' => ENV['LD_LIBRARY_PATH'],
'LANG' => ENV['LANG'], 'LANG' => ENV['LANG'],
'GL_ID' => @key_id 'GL_ID' => @key_id,
'PROTOCOL' => 'ssh'
} }
if @config.git_annex_enabled? if @config.git_annex_enabled?
......
...@@ -242,7 +242,7 @@ describe GitlabShell do ...@@ -242,7 +242,7 @@ describe GitlabShell do
after { subject.exec(ssh_cmd) } after { subject.exec(ssh_cmd) }
it "should call api.check_access" do 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 end
it "should disallow access and log the attempt if check_access returns false status" do 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