From 95049f969d344409eae87cb84ccc98a6bff8220f Mon Sep 17 00:00:00 2001 From: "Hall, Cam" Date: Wed, 13 Apr 2016 16:30:11 +0200 Subject: [PATCH] Prevent custom_hooks pre-receive from freezing Fixes gitlab-org/gitlab-ce#1458 --- CHANGELOG | 3 +++ lib/gitlab_custom_hook.rb | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 63b04cc5b..bf7a1a055 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +V3.0.1 + - Prevent custom_hooks pre-receive from freezing + v3.0.0 - Remove rm-tag command (Robert Schilling) - Remove create-branch and rm-branch commands (Robert Schilling) diff --git a/lib/gitlab_custom_hook.rb b/lib/gitlab_custom_hook.rb index ac6837de2..ffd369e79 100644 --- a/lib/gitlab_custom_hook.rb +++ b/lib/gitlab_custom_hook.rb @@ -33,6 +33,7 @@ class GitlabCustomHook Open3.popen2e(hook) do |stdin, stdout_stderr, wait_thr| exit_status = true stdin.sync = true + $stdout.sync = true # in git, pre- and post- receive hooks may just exit without # reading stdin. We catch the exception to avoid a broken pipe @@ -48,11 +49,12 @@ class GitlabCustomHook # need to close stdin before reading stdout stdin.close + stdout_stderr.each_line { |line| puts line } + unless wait_thr.value == 0 exit_status = false end - stdout_stderr.each_line { |line| puts line } end exit_status -- GitLab