diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-04-06 12:41:38 +0200 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-04-06 13:10:10 +0200 |
commit | e8403e8bb7c5c9109af83a183943d5361ad1409b (patch) | |
tree | 0fe3e73b6695816c3ce0a8f01f9fb8cac29a1a9f | |
parent | f64e5d4a075479846f2e18bb34b84eb26d180f57 (diff) | |
download | gitlab-shell-e8403e8bb7c5c9109af83a183943d5361ad1409b.tar.gz |
Move setting/unsetting of GL_ID from lib to executables.
-rwxr-xr-x | hooks/post-receive | 3 | ||||
-rw-r--r-- | lib/gitlab_custom_hook.rb | 13 | ||||
-rw-r--r-- | lib/gitlab_post_receive.rb | 4 | ||||
-rw-r--r-- | spec/gitlab_post_receive_spec.rb | 8 |
4 files changed, 8 insertions, 20 deletions
diff --git a/hooks/post-receive b/hooks/post-receive index 301f639..da0ff41 100755 --- a/hooks/post-receive +++ b/hooks/post-receive @@ -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' diff --git a/lib/gitlab_custom_hook.rb b/lib/gitlab_custom_hook.rb index a099e79..ac6837d 100644 --- a/lib/gitlab_custom_hook.rb +++ b/lib/gitlab_custom_hook.rb @@ -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 diff --git a/lib/gitlab_post_receive.rb b/lib/gitlab_post_receive.rb index 3c601ee..ede64f2 100644 --- a/lib/gitlab_post_receive.rb +++ b/lib/gitlab_post_receive.rb @@ -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 diff --git a/spec/gitlab_post_receive_spec.rb b/spec/gitlab_post_receive_spec.rb index 5a9892a..3c1f362 100644 --- a/spec/gitlab_post_receive_spec.rb +++ b/spec/gitlab_post_receive_spec.rb @@ -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( |