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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
926a8ab4
Commit
926a8ab4
authored
Jul 04, 2016
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle custom Git hook result in GitLab UI
parent
f60b48bd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
3 deletions
+22
-3
CHANGELOG
CHANGELOG
+1
-0
app/services/merge_requests/merge_service.rb
app/services/merge_requests/merge_service.rb
+4
-1
lib/gitlab/git/hook.rb
lib/gitlab/git/hook.rb
+7
-2
spec/services/merge_requests/merge_service_spec.rb
spec/services/merge_requests/merge_service_spec.rb
+10
-0
No files found.
CHANGELOG
View file @
926a8ab4
...
@@ -33,6 +33,7 @@ v 8.10.0 (unreleased)
...
@@ -33,6 +33,7 @@ v 8.10.0 (unreleased)
- Add basic system information like memory and disk usage to the admin panel
- Add basic system information like memory and disk usage to the admin panel
- Don't garbage collect commits that have related DB records like comments
- Don't garbage collect commits that have related DB records like comments
- More descriptive message for git hooks and file locks
- More descriptive message for git hooks and file locks
- Handle custom Git hook result in GitLab UI
v 8.9.5 (unreleased)
v 8.9.5 (unreleased)
- Improve the request / withdraw access button. !4860
- Improve the request / withdraw access button. !4860
...
...
app/services/merge_requests/merge_service.rb
View file @
926a8ab4
...
@@ -36,10 +36,13 @@ module MergeRequests
...
@@ -36,10 +36,13 @@ module MergeRequests
commit_id
=
repository
.
merge
(
current_user
,
merge_request
.
source_sha
,
merge_request
.
target_branch
,
options
)
commit_id
=
repository
.
merge
(
current_user
,
merge_request
.
source_sha
,
merge_request
.
target_branch
,
options
)
merge_request
.
update
(
merge_commit_sha:
commit_id
)
merge_request
.
update
(
merge_commit_sha:
commit_id
)
rescue
GitHooksService
::
PreReceiveError
=>
e
merge_request
.
update
(
merge_error:
e
.
message
)
false
rescue
StandardError
=>
e
rescue
StandardError
=>
e
merge_request
.
update
(
merge_error:
"Something went wrong during merge"
)
merge_request
.
update
(
merge_error:
"Something went wrong during merge"
)
Rails
.
logger
.
error
(
e
.
message
)
Rails
.
logger
.
error
(
e
.
message
)
return
false
false
end
end
def
after_merge
def
after_merge
...
...
lib/gitlab/git/hook.rb
View file @
926a8ab4
...
@@ -41,7 +41,7 @@ module Gitlab
...
@@ -41,7 +41,7 @@ module Gitlab
chdir:
repo_path
chdir:
repo_path
}
}
Open3
.
popen3
(
vars
,
path
,
options
)
do
|
stdin
,
_
,
stderr
,
wait_thr
|
Open3
.
popen3
(
vars
,
path
,
options
)
do
|
stdin
,
stdout
,
stderr
,
wait_thr
|
exit_status
=
true
exit_status
=
true
stdin
.
sync
=
true
stdin
.
sync
=
true
...
@@ -60,7 +60,7 @@ module Gitlab
...
@@ -60,7 +60,7 @@ module Gitlab
unless
wait_thr
.
value
==
0
unless
wait_thr
.
value
==
0
exit_status
=
false
exit_status
=
false
exit_message
=
stderr
.
gets
exit_message
=
retrieve_error_message
(
stderr
,
stdout
)
end
end
end
end
...
@@ -76,6 +76,11 @@ module Gitlab
...
@@ -76,6 +76,11 @@ module Gitlab
[
status
,
nil
]
[
status
,
nil
]
end
end
def
retrieve_error_message
(
stderr
,
stdout
)
err_message
=
stderr
.
gets
err_message
.
blank?
?
stdout
.
gets
:
err_message
end
end
end
end
end
end
end
spec/services/merge_requests/merge_service_spec.rb
View file @
926a8ab4
...
@@ -65,6 +65,16 @@ describe MergeRequests::MergeService, services: true do
...
@@ -65,6 +65,16 @@ describe MergeRequests::MergeService, services: true do
expect
(
merge_request
.
merge_error
).
to
eq
(
"Something went wrong during merge"
)
expect
(
merge_request
.
merge_error
).
to
eq
(
"Something went wrong during merge"
)
end
end
it
'saves error if there is an PreReceiveError exception'
do
allow
(
service
).
to
receive
(
:repository
).
and_raise
(
GitHooksService
::
PreReceiveError
,
"error"
)
allow
(
service
).
to
receive
(
:execute_hooks
)
service
.
execute
(
merge_request
)
expect
(
merge_request
.
merge_error
).
to
eq
(
"error"
)
end
end
end
end
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