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
b4e3dc95
Commit
b4e3dc95
authored
May 21, 2020
by
Rajendra Kadam
Committed by
Peter Leitzen
May 21, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use applogger in merge_service.rb
parent
11271ac4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
13 deletions
+18
-13
app/services/merge_requests/merge_service.rb
app/services/merge_requests/merge_service.rb
+2
-2
changelogs/unreleased/rails-logger-cop-12.yml
changelogs/unreleased/rails-logger-cop-12.yml
+5
-0
spec/services/merge_requests/ff_merge_service_spec.rb
spec/services/merge_requests/ff_merge_service_spec.rb
+3
-3
spec/services/merge_requests/merge_service_spec.rb
spec/services/merge_requests/merge_service_spec.rb
+8
-8
No files found.
app/services/merge_requests/merge_service.rb
View file @
b4e3dc95
...
@@ -121,12 +121,12 @@ module MergeRequests
...
@@ -121,12 +121,12 @@ module MergeRequests
end
end
def
handle_merge_error
(
log_message
:,
save_message_on_model:
false
)
def
handle_merge_error
(
log_message
:,
save_message_on_model:
false
)
Rails
.
logger
.
error
(
"MergeService ERROR:
#{
merge_request_info
}
-
#{
log_message
}
"
)
# rubocop:disable Gitlab/RailsLogger
Gitlab
::
AppLogger
.
error
(
"MergeService ERROR:
#{
merge_request_info
}
-
#{
log_message
}
"
)
@merge_request
.
update
(
merge_error:
log_message
)
if
save_message_on_model
@merge_request
.
update
(
merge_error:
log_message
)
if
save_message_on_model
end
end
def
log_info
(
message
)
def
log_info
(
message
)
@logger
||=
Rails
.
logger
# rubocop:disable Gitlab/Rails
Logger
@logger
||=
Gitlab
::
App
Logger
@logger
.
info
(
"
#{
merge_request_info
}
-
#{
message
}
"
)
@logger
.
info
(
"
#{
merge_request_info
}
-
#{
message
}
"
)
end
end
...
...
changelogs/unreleased/rails-logger-cop-12.yml
0 → 100644
View file @
b4e3dc95
---
title
:
Use applogger in merge_service.rb
merge_request
:
32196
author
:
Rajendra Kadam
type
:
fixed
spec/services/merge_requests/ff_merge_service_spec.rb
View file @
b4e3dc95
...
@@ -87,7 +87,7 @@ describe MergeRequests::FfMergeService do
...
@@ -87,7 +87,7 @@ describe MergeRequests::FfMergeService do
let
(
:service
)
{
described_class
.
new
(
project
,
user
,
valid_merge_params
.
merge
(
commit_message:
'Awesome message'
))
}
let
(
:service
)
{
described_class
.
new
(
project
,
user
,
valid_merge_params
.
merge
(
commit_message:
'Awesome message'
))
}
before
do
before
do
allow
(
Rails
.
l
ogger
).
to
receive
(
:error
)
allow
(
Gitlab
::
AppL
ogger
).
to
receive
(
:error
)
end
end
it
'logs and saves error if there is an exception'
do
it
'logs and saves error if there is an exception'
do
...
@@ -99,7 +99,7 @@ describe MergeRequests::FfMergeService do
...
@@ -99,7 +99,7 @@ describe MergeRequests::FfMergeService do
service
.
execute
(
merge_request
)
service
.
execute
(
merge_request
)
expect
(
merge_request
.
merge_error
).
to
include
(
error_message
)
expect
(
merge_request
.
merge_error
).
to
include
(
error_message
)
expect
(
Rails
.
l
ogger
).
to
have_received
(
:error
).
with
(
a_string_matching
(
error_message
))
expect
(
Gitlab
::
AppL
ogger
).
to
have_received
(
:error
).
with
(
a_string_matching
(
error_message
))
end
end
it
'logs and saves error if there is an PreReceiveError exception'
do
it
'logs and saves error if there is an PreReceiveError exception'
do
...
@@ -111,7 +111,7 @@ describe MergeRequests::FfMergeService do
...
@@ -111,7 +111,7 @@ describe MergeRequests::FfMergeService do
service
.
execute
(
merge_request
)
service
.
execute
(
merge_request
)
expect
(
merge_request
.
merge_error
).
to
include
(
error_message
)
expect
(
merge_request
.
merge_error
).
to
include
(
error_message
)
expect
(
Rails
.
l
ogger
).
to
have_received
(
:error
).
with
(
a_string_matching
(
error_message
))
expect
(
Gitlab
::
AppL
ogger
).
to
have_received
(
:error
).
with
(
a_string_matching
(
error_message
))
end
end
it
'does not update squash_commit_sha if squash merge is not successful'
do
it
'does not update squash_commit_sha if squash merge is not successful'
do
...
...
spec/services/merge_requests/merge_service_spec.rb
View file @
b4e3dc95
...
@@ -277,7 +277,7 @@ describe MergeRequests::MergeService do
...
@@ -277,7 +277,7 @@ describe MergeRequests::MergeService do
context
'error handling'
do
context
'error handling'
do
before
do
before
do
allow
(
Rails
.
l
ogger
).
to
receive
(
:error
)
allow
(
Gitlab
::
AppL
ogger
).
to
receive
(
:error
)
end
end
context
'when source is missing'
do
context
'when source is missing'
do
...
@@ -289,7 +289,7 @@ describe MergeRequests::MergeService do
...
@@ -289,7 +289,7 @@ describe MergeRequests::MergeService do
service
.
execute
(
merge_request
)
service
.
execute
(
merge_request
)
expect
(
merge_request
.
merge_error
).
to
eq
(
error_message
)
expect
(
merge_request
.
merge_error
).
to
eq
(
error_message
)
expect
(
Rails
.
l
ogger
).
to
have_received
(
:error
).
with
(
a_string_matching
(
error_message
))
expect
(
Gitlab
::
AppL
ogger
).
to
have_received
(
:error
).
with
(
a_string_matching
(
error_message
))
end
end
end
end
...
@@ -302,7 +302,7 @@ describe MergeRequests::MergeService do
...
@@ -302,7 +302,7 @@ describe MergeRequests::MergeService do
service
.
execute
(
merge_request
)
service
.
execute
(
merge_request
)
expect
(
merge_request
.
merge_error
).
to
include
(
'Something went wrong during merge'
)
expect
(
merge_request
.
merge_error
).
to
include
(
'Something went wrong during merge'
)
expect
(
Rails
.
l
ogger
).
to
have_received
(
:error
).
with
(
a_string_matching
(
error_message
))
expect
(
Gitlab
::
AppL
ogger
).
to
have_received
(
:error
).
with
(
a_string_matching
(
error_message
))
end
end
it
'logs and saves error if user is not authorized'
do
it
'logs and saves error if user is not authorized'
do
...
@@ -326,7 +326,7 @@ describe MergeRequests::MergeService do
...
@@ -326,7 +326,7 @@ describe MergeRequests::MergeService do
service
.
execute
(
merge_request
)
service
.
execute
(
merge_request
)
expect
(
merge_request
.
merge_error
).
to
include
(
'Something went wrong during merge pre-receive hook'
)
expect
(
merge_request
.
merge_error
).
to
include
(
'Something went wrong during merge pre-receive hook'
)
expect
(
Rails
.
l
ogger
).
to
have_received
(
:error
).
with
(
a_string_matching
(
error_message
))
expect
(
Gitlab
::
AppL
ogger
).
to
have_received
(
:error
).
with
(
a_string_matching
(
error_message
))
end
end
it
'logs and saves error if there is a merge conflict'
do
it
'logs and saves error if there is a merge conflict'
do
...
@@ -340,7 +340,7 @@ describe MergeRequests::MergeService do
...
@@ -340,7 +340,7 @@ describe MergeRequests::MergeService do
expect
(
merge_request
).
to
be_open
expect
(
merge_request
).
to
be_open
expect
(
merge_request
.
merge_commit_sha
).
to
be_nil
expect
(
merge_request
.
merge_commit_sha
).
to
be_nil
expect
(
merge_request
.
merge_error
).
to
include
(
error_message
)
expect
(
merge_request
.
merge_error
).
to
include
(
error_message
)
expect
(
Rails
.
l
ogger
).
to
have_received
(
:error
).
with
(
a_string_matching
(
error_message
))
expect
(
Gitlab
::
AppL
ogger
).
to
have_received
(
:error
).
with
(
a_string_matching
(
error_message
))
end
end
context
'when squashing'
do
context
'when squashing'
do
...
@@ -359,7 +359,7 @@ describe MergeRequests::MergeService do
...
@@ -359,7 +359,7 @@ describe MergeRequests::MergeService do
expect
(
merge_request
).
to
be_open
expect
(
merge_request
).
to
be_open
expect
(
merge_request
.
merge_commit_sha
).
to
be_nil
expect
(
merge_request
.
merge_commit_sha
).
to
be_nil
expect
(
merge_request
.
merge_error
).
to
include
(
error_message
)
expect
(
merge_request
.
merge_error
).
to
include
(
error_message
)
expect
(
Rails
.
l
ogger
).
to
have_received
(
:error
).
with
(
a_string_matching
(
error_message
))
expect
(
Gitlab
::
AppL
ogger
).
to
have_received
(
:error
).
with
(
a_string_matching
(
error_message
))
end
end
it
'logs and saves error if there is a squash in progress'
do
it
'logs and saves error if there is a squash in progress'
do
...
@@ -373,7 +373,7 @@ describe MergeRequests::MergeService do
...
@@ -373,7 +373,7 @@ describe MergeRequests::MergeService do
expect
(
merge_request
).
to
be_open
expect
(
merge_request
).
to
be_open
expect
(
merge_request
.
merge_commit_sha
).
to
be_nil
expect
(
merge_request
.
merge_commit_sha
).
to
be_nil
expect
(
merge_request
.
merge_error
).
to
include
(
error_message
)
expect
(
merge_request
.
merge_error
).
to
include
(
error_message
)
expect
(
Rails
.
l
ogger
).
to
have_received
(
:error
).
with
(
a_string_matching
(
error_message
))
expect
(
Gitlab
::
AppL
ogger
).
to
have_received
(
:error
).
with
(
a_string_matching
(
error_message
))
end
end
context
'when fast-forward merge is not allowed'
do
context
'when fast-forward merge is not allowed'
do
...
@@ -393,7 +393,7 @@ describe MergeRequests::MergeService do
...
@@ -393,7 +393,7 @@ describe MergeRequests::MergeService do
expect
(
merge_request
).
to
be_open
expect
(
merge_request
).
to
be_open
expect
(
merge_request
.
merge_commit_sha
).
to
be_nil
expect
(
merge_request
.
merge_commit_sha
).
to
be_nil
expect
(
merge_request
.
merge_error
).
to
include
(
error_message
)
expect
(
merge_request
.
merge_error
).
to
include
(
error_message
)
expect
(
Rails
.
l
ogger
).
to
have_received
(
:error
).
with
(
a_string_matching
(
error_message
))
expect
(
Gitlab
::
AppL
ogger
).
to
have_received
(
:error
).
with
(
a_string_matching
(
error_message
))
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