summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2016-07-21 18:33:39 +0000
committerRobert Speicher <robert@gitlab.com>2016-07-21 18:33:39 +0000
commit2e2af9ac3b79aff92afad0f3f8cee60646f1128b (patch)
tree6c8c328c91bb6fffe88967ed5f36d44dc852c898
parente8a4dc7018bba7f0321ce8d5d7758629c6503075 (diff)
parentc1587190db9bb3bbc3bd87a6e95b430b51b55686 (diff)
downloadgitlab-shell-2e2af9ac3b79aff92afad0f3f8cee60646f1128b.tar.gz
Merge branch 'remove-env-set' into 'master'
Unset GL_ID and GL_PROTOCOL immediately Neither other code executing in the hook process nor subprocesses of the hook process need access to the GL_ID / GL_PROTOCOL variables so we can just unset them the moment we fetch them. See merge request !73
-rwxr-xr-xbin/gitlab-shell2
-rwxr-xr-xhooks/post-receive5
-rwxr-xr-xhooks/pre-receive7
3 files changed, 4 insertions, 10 deletions
diff --git a/bin/gitlab-shell b/bin/gitlab-shell
index f145a1b..6ef572f 100755
--- a/bin/gitlab-shell
+++ b/bin/gitlab-shell
@@ -6,7 +6,7 @@ unless ENV['SSH_CONNECTION']
end
key_id = /key-[0-9]+/.match(ARGV.join).to_s
-original_cmd = ENV['SSH_ORIGINAL_COMMAND']
+original_cmd = ENV.delete('SSH_ORIGINAL_COMMAND')
require_relative '../lib/gitlab_init'
diff --git a/hooks/post-receive b/hooks/post-receive
index 34802e5..b7bc85e 100755
--- a/hooks/post-receive
+++ b/hooks/post-receive
@@ -4,12 +4,9 @@
# will be processed properly.
refs = $stdin.read
-key_id = ENV['GL_ID']
+key_id = ENV.delete('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/hooks/pre-receive b/hooks/pre-receive
index a4b2e32..66cb97d 100755
--- a/hooks/pre-receive
+++ b/hooks/pre-receive
@@ -4,8 +4,8 @@
# will be processed properly.
refs = $stdin.read
-key_id = ENV['GL_ID']
-protocol = ENV['GL_PROTOCOL']
+key_id = ENV.delete('GL_ID')
+protocol = ENV.delete('GL_PROTOCOL')
repo_path = Dir.pwd
require_relative '../lib/gitlab_custom_hook'
@@ -15,8 +15,5 @@ if GitlabAccess.new(repo_path, key_id, refs, protocol).exec &&
GitlabCustomHook.new.pre_receive(refs, repo_path)
exit 0
else
- # reset GL_ID env since we stop git push here
- ENV['GL_ID'] = nil
-
exit 1
end