diff options
author | Patricio Cano <suprnova32@gmail.com> | 2016-06-20 21:57:37 -0500 |
---|---|---|
committer | Patricio Cano <suprnova32@gmail.com> | 2016-07-05 18:03:29 -0500 |
commit | fd41b8a433164f36f7cf70b358115c5f56f06670 (patch) | |
tree | c5bf7d25769590aca26dba99626a6c51ef498508 | |
parent | 1c18095c9f2b80d380122c8c71f98a07387c1e66 (diff) | |
download | gitlab-shell-fd41b8a433164f36f7cf70b358115c5f56f06670.tar.gz |
Simplify protocol assign, and populate ENV['PROTOCOL'] variable when calling hooks via SSH
-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 |