summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-02-06 19:17:22 +0000
committerStan Hu <stanhu@gmail.com>2018-02-06 19:17:22 +0000
commitbc59a5d0a52d7ccf6e61468ec72346b57e6f4265 (patch)
tree2df59c5eaec283a99b385876794b6666f5e60e80 /lib
parent3f3b84e026aa79535fa639bf08962e7b7c6b63cd (diff)
parent81b5ce11525c93c479041a31257f522f03c9d129 (diff)
downloadgitlab-ce-bc59a5d0a52d7ccf6e61468ec72346b57e6f4265.tar.gz
Merge branch 'dm-git-hook-popen' into 'master'
Only set cwd on the newly spawned process, instead of the current one See merge request gitlab-org/gitlab-ce!16958
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/git/hook.rb22
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)