Skip to content

Commit 2e2af9a

Browse files
author
Robert Speicher
committed
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
2 parents e8a4dc7 + c158719 commit 2e2af9a

File tree

3 files changed

+4
-10
lines changed

3 files changed

+4
-10
lines changed

bin/gitlab-shell

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ unless ENV['SSH_CONNECTION']
66
end
77

88
key_id = /key-[0-9]+/.match(ARGV.join).to_s
9-
original_cmd = ENV['SSH_ORIGINAL_COMMAND']
9+
original_cmd = ENV.delete('SSH_ORIGINAL_COMMAND')
1010

1111
require_relative '../lib/gitlab_init'
1212

hooks/post-receive

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@
44
# will be processed properly.
55

66
refs = $stdin.read
7-
key_id = ENV['GL_ID']
7+
key_id = ENV.delete('GL_ID')
88
repo_path = Dir.pwd
99

10-
# reset GL_ID env since we already got its value
11-
ENV['GL_ID'] = nil
12-
1310
require_relative '../lib/gitlab_custom_hook'
1411
require_relative '../lib/gitlab_post_receive'
1512

hooks/pre-receive

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
# will be processed properly.
55

66
refs = $stdin.read
7-
key_id = ENV['GL_ID']
8-
protocol = ENV['GL_PROTOCOL']
7+
key_id = ENV.delete('GL_ID')
8+
protocol = ENV.delete('GL_PROTOCOL')
99
repo_path = Dir.pwd
1010

1111
require_relative '../lib/gitlab_custom_hook'
@@ -15,8 +15,5 @@ if GitlabAccess.new(repo_path, key_id, refs, protocol).exec &&
1515
GitlabCustomHook.new.pre_receive(refs, repo_path)
1616
exit 0
1717
else
18-
# reset GL_ID env since we stop git push here
19-
ENV['GL_ID'] = nil
20-
2118
exit 1
2219
end

0 commit comments

Comments
 (0)