Commit e8403e8b authored by Douwe Maan's avatar Douwe Maan

Move setting/unsetting of GL_ID from lib to executables.

parent f64e5d4a
......@@ -7,6 +7,9 @@ refs = ARGF.read
key_id = ENV['GL_ID']
repo_path = Dir.pwd
# reset GL_ID env since we already got its value
ENV['GL_ID'] = nil
require_relative '../lib/gitlab_custom_hook'
require_relative '../lib/gitlab_post_receive'
......
......@@ -4,24 +4,21 @@ class GitlabCustomHook
def pre_receive(changes, repo_path)
hook = hook_file('pre-receive', repo_path)
return true if hook.nil?
if call_receive_hook(hook, changes)
return true
else
# reset GL_ID env since we stop git push here
ENV['GL_ID'] = nil
return false
end
call_receive_hook(hook, changes)
end
def post_receive(changes, repo_path)
hook = hook_file('post-receive', repo_path)
return true if hook.nil?
call_receive_hook(hook, changes) ? true : false
call_receive_hook(hook, changes)
end
def update(ref_name, old_value, new_value, repo_path)
hook = hook_file('update', repo_path)
return true if hook.nil?
system(hook, ref_name, old_value, new_value)
end
......
......@@ -13,10 +13,6 @@ class GitlabPostReceive
end
def exec
# reset GL_ID env since we already
# get value from it
ENV['GL_ID'] = nil
result = update_redis
begin
......
......@@ -24,14 +24,6 @@ describe GitlabPostReceive do
allow(gitlab_post_receive).to receive(:system).and_return(true)
end
it "resets the GL_ID environment variable" do
ENV["GL_ID"] = actor
gitlab_post_receive.exec
expect(ENV["GL_ID"]).to be_nil
end
it "prints the broadcast message" do
expect(gitlab_post_receive).to receive(:puts).ordered
expect(gitlab_post_receive).to receive(:puts).with(
......
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