Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
fbe205f9
Commit
fbe205f9
authored
Sep 11, 2017
by
Robin Bobbitt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Display full pre-receive and post-receive hook output in GitLab UI
parent
cfccb278
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
4 deletions
+11
-4
changelogs/unreleased/fix-multi-line-hook-output.yml
changelogs/unreleased/fix-multi-line-hook-output.yml
+5
-0
lib/gitlab/git/hook.rb
lib/gitlab/git/hook.rb
+4
-3
spec/lib/gitlab/git/hook_spec.rb
spec/lib/gitlab/git/hook_spec.rb
+2
-1
No files found.
changelogs/unreleased/fix-multi-line-hook-output.yml
0 → 100644
View file @
fbe205f9
---
title
:
Display full pre-receive and post-receive hook output in GitLab UI
merge_request
:
14222
author
:
Robin Bobbitt
type
:
fixed
lib/gitlab/git/hook.rb
View file @
fbe205f9
...
...
@@ -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
...
...
spec/lib/gitlab/git/hook_spec.rb
View file @
fbe205f9
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment