diff options
author | Robin Bobbitt <ryehle@us.ibm.com> | 2017-09-11 22:50:12 -0400 |
---|---|---|
committer | Robin Bobbitt <ryehle@us.ibm.com> | 2017-09-21 09:13:00 -0400 |
commit | fbe205f92f144185a12d5c05e5094e831c14913c (patch) | |
tree | c61ecd0a81c770fde286db7ed9684c72d8c8b2f8 | |
parent | cfccb2785fb8b98a013170aae4b931e9431739d1 (diff) | |
download | gitlab-ce-fbe205f92f144185a12d5c05e5094e831c14913c.tar.gz |
Display full pre-receive and post-receive hook output in GitLab UI
-rw-r--r-- | changelogs/unreleased/fix-multi-line-hook-output.yml | 5 | ||||
-rw-r--r-- | lib/gitlab/git/hook.rb | 7 | ||||
-rw-r--r-- | spec/lib/gitlab/git/hook_spec.rb | 3 |
3 files changed, 11 insertions, 4 deletions
diff --git a/changelogs/unreleased/fix-multi-line-hook-output.yml b/changelogs/unreleased/fix-multi-line-hook-output.yml new file mode 100644 index 00000000000..f625ec2ee6c --- /dev/null +++ b/changelogs/unreleased/fix-multi-line-hook-output.yml @@ -0,0 +1,5 @@ +--- +title: Display full pre-receive and post-receive hook output in GitLab UI +merge_request: 14222 +author: Robin Bobbitt +type: fixed diff --git a/lib/gitlab/git/hook.rb b/lib/gitlab/git/hook.rb index cc35d77c6e4..208e4bbaf60 100644 --- a/lib/gitlab/git/hook.rb +++ b/lib/gitlab/git/hook.rb @@ -83,13 +83,14 @@ module Gitlab def call_update_hook(gl_id, oldrev, newrev, ref) Dir.chdir(repo_path) do stdout, stderr, status = Open3.capture3({ 'GL_ID' => gl_id }, path, ref, oldrev, newrev) - [status.success?, stderr.presence || stdout] + [status.success?, (stderr.presence || stdout).gsub(/\R/, "<br>").html_safe] end end def retrieve_error_message(stderr, stdout) - err_message = stderr.gets - err_message.blank? ? stdout.gets : err_message + err_message = stderr.read + err_message = err_message.blank? ? stdout.read : err_message + err_message.gsub(/\R/, "<br>").html_safe end end end diff --git a/spec/lib/gitlab/git/hook_spec.rb b/spec/lib/gitlab/git/hook_spec.rb index ea3e4680b1d..0ff4f3bd105 100644 --- a/spec/lib/gitlab/git/hook_spec.rb +++ b/spec/lib/gitlab/git/hook_spec.rb @@ -28,6 +28,7 @@ describe Gitlab::Git::Hook do f.write(<<-HOOK) echo 'regular message from the hook' echo 'error message from the hook' 1>&2 + echo 'error message from the hook line 2' 1>&2 exit 1 HOOK end @@ -73,7 +74,7 @@ describe Gitlab::Git::Hook do status, errors = hook.trigger(gl_id, blank, blank, ref) expect(status).to be false - expect(errors).to eq("error message from the hook\n") + expect(errors).to eq("error message from the hook<br>error message from the hook line 2<br>") end end end |