diff options
author | Douwe Maan <douwe@selenight.nl> | 2018-02-06 12:19:48 -0600 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2018-02-06 12:19:48 -0600 |
commit | 81b5ce11525c93c479041a31257f522f03c9d129 (patch) | |
tree | d433267c46a93cdb06bdca711f53f35ae1b72b09 /lib | |
parent | 4900390711305ec05e514e7077ab99713d68ff6b (diff) | |
download | gitlab-ce-81b5ce11525c93c479041a31257f522f03c9d129.tar.gz |
Only set cwd on the newly spawned process, instead of the current one
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/git/hook.rb | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/lib/gitlab/git/hook.rb b/lib/gitlab/git/hook.rb index e29a1f7afa1..24f027d8da4 100644 --- a/lib/gitlab/git/hook.rb +++ b/lib/gitlab/git/hook.rb @@ -82,14 +82,20 @@ module Gitlab end def call_update_hook(gl_id, gl_username, oldrev, newrev, ref) - Dir.chdir(repo_path) do - env = { - 'GL_ID' => gl_id, - 'GL_USERNAME' => gl_username - } - stdout, stderr, status = Open3.capture3(env, path, ref, oldrev, newrev) - [status.success?, (stderr.presence || stdout).gsub(/\R/, "<br>").html_safe] - end + env = { + 'GL_ID' => gl_id, + 'GL_USERNAME' => gl_username, + 'PWD' => repo_path + } + + options = { + chdir: repo_path + } + + args = [ref, oldrev, newrev] + + stdout, stderr, status = Open3.capture3(env, path, *args, options) + [status.success?, (stderr.presence || stdout).gsub(/\R/, "<br>").html_safe] end def retrieve_error_message(stderr, stdout) |