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
47b0edbe
Commit
47b0edbe
authored
Oct 18, 2016
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve error logging of MergeService
Relates to #23505
parent
f64e36c4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
6 deletions
+12
-6
app/services/merge_requests/merge_service.rb
app/services/merge_requests/merge_service.rb
+10
-4
spec/services/merge_requests/merge_service_spec.rb
spec/services/merge_requests/merge_service_spec.rb
+2
-2
No files found.
app/services/merge_requests/merge_service.rb
View file @
47b0edbe
...
...
@@ -11,14 +11,14 @@ module MergeRequests
def
execute
(
merge_request
)
@merge_request
=
merge_request
return
error
(
'Merge request is not mergeable'
)
unless
@merge_request
.
mergeable?
return
log_merge_error
(
'Merge request is not mergeable'
,
true
)
unless
@merge_request
.
mergeable?
merge_request
.
in_locked_state
do
if
commit
after_merge
success
else
error
(
'Can not merge changes'
)
log_merge_error
(
'Can not merge changes'
,
true
)
end
end
end
...
...
@@ -46,8 +46,8 @@ module MergeRequests
merge_request
.
update
(
merge_error:
e
.
message
)
false
rescue
StandardError
=>
e
merge_request
.
update
(
merge_error:
"Something went wrong during merge"
)
Rails
.
logger
.
error
(
e
.
message
)
merge_request
.
update
(
merge_error:
"Something went wrong during merge
:
#{
e
.
message
}
"
)
log_merge_
error
(
e
.
message
)
false
ensure
merge_request
.
update
(
in_progress_merge_commit_sha:
nil
)
...
...
@@ -65,5 +65,11 @@ module MergeRequests
def
branch_deletion_user
@merge_request
.
force_remove_source_branch?
?
@merge_request
.
author
:
current_user
end
def
log_merge_error
(
message
,
http_error
=
false
)
Rails
.
logger
.
error
(
"MergeService error:
#{
message
}
"
)
error
(
message
)
if
http_error
end
end
end
spec/services/merge_requests/merge_service_spec.rb
View file @
47b0edbe
...
...
@@ -120,13 +120,13 @@ describe MergeRequests::MergeService, services: true do
let
(
:service
)
{
MergeRequests
::
MergeService
.
new
(
project
,
user
,
commit_message:
'Awesome message'
)
}
it
'saves error if there is an exception'
do
allow
(
service
).
to
receive
(
:repository
).
and_raise
(
"error"
)
allow
(
service
).
to
receive
(
:repository
).
and_raise
(
"error
message
"
)
allow
(
service
).
to
receive
(
:execute_hooks
)
service
.
execute
(
merge_request
)
expect
(
merge_request
.
merge_error
).
to
eq
(
"Something went wrong during merge"
)
expect
(
merge_request
.
merge_error
).
to
eq
(
"Something went wrong during merge
: error message
"
)
end
it
'saves error if there is an PreReceiveError exception'
do
...
...
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