Commit e794bdf3 authored by Christian Höltje's avatar Christian Höltje

Use Kernel::exec instead of system()

We don't need to keep the ruby process around once we've
established that it's ok to run a git command.
parent 0c6686b6
...@@ -44,13 +44,17 @@ class GitlabShell ...@@ -44,13 +44,17 @@ class GitlabShell
def process_cmd def process_cmd
repo_full_path = File.join(repos_path, repo_name) repo_full_path = File.join(repos_path, repo_name)
system("#{@git_cmd} #{repo_full_path}") exec_cmd "#{@git_cmd} #{repo_full_path}"
end end
def validate_access def validate_access
api.allowed?(@git_cmd, @repo_name, @key_id, '_any') api.allowed?(@git_cmd, @repo_name, @key_id, '_any')
end end
def exec_cmd args
Kernel::exec args
end
def api def api
GitlabNet.new GitlabNet.new
end end
......
...@@ -5,7 +5,7 @@ describe GitlabShell do ...@@ -5,7 +5,7 @@ describe GitlabShell do
subject do subject do
ARGV[0] = 'key-56' ARGV[0] = 'key-56'
GitlabShell.new.tap do |shell| GitlabShell.new.tap do |shell|
shell.stub(process_cmd: true) shell.stub(exec_cmd: :exec_called)
shell.stub(api: api) shell.stub(api: api)
end end
end end
...@@ -53,6 +53,10 @@ describe GitlabShell do ...@@ -53,6 +53,10 @@ describe GitlabShell do
it "should process the command" do it "should process the command" do
subject.should_receive(:process_cmd).with() subject.should_receive(:process_cmd).with()
end end
it "should execute the command" do
subject.should_receive(:exec_cmd).with("git-upload-pack /home/git/repositories/gitlab-ci.git")
end
end end
context 'git-receive-pack' do context 'git-receive-pack' do
...@@ -62,6 +66,10 @@ describe GitlabShell do ...@@ -62,6 +66,10 @@ describe GitlabShell do
it "should process the command" do it "should process the command" do
subject.should_receive(:process_cmd).with() subject.should_receive(:process_cmd).with()
end end
it "should execute the command" do
subject.should_receive(:exec_cmd).with("git-receive-pack /home/git/repositories/gitlab-ci.git")
end
end end
context 'arbitrary command' do context 'arbitrary command' do
...@@ -71,6 +79,10 @@ describe GitlabShell do ...@@ -71,6 +79,10 @@ describe GitlabShell do
it "should not process the command" do it "should not process the command" do
subject.should_not_receive(:process_cmd) subject.should_not_receive(:process_cmd)
end end
it "should not execute the command" do
subject.should_not_receive(:exec_cmd)
end
end end
context 'no command' do context 'no command' 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