Display full pre-receive and post-receive hook output in GitLab UI
This commit is contained in:
parent
cfccb2785f
commit
fbe205f92f
3 changed files with 11 additions and 4 deletions
5
changelogs/unreleased/fix-multi-line-hook-output.yml
Normal file
5
changelogs/unreleased/fix-multi-line-hook-output.yml
Normal file
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue