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
7b6128a0
Commit
7b6128a0
authored
Nov 17, 2020
by
fjsanpedro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve snippet log message
parent
fff2665b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
7 deletions
+9
-7
app/services/snippets/create_service.rb
app/services/snippets/create_service.rb
+1
-1
app/services/snippets/update_service.rb
app/services/snippets/update_service.rb
+1
-1
spec/services/snippets/create_service_spec.rb
spec/services/snippets/create_service_spec.rb
+4
-2
spec/services/snippets/update_service_spec.rb
spec/services/snippets/update_service_spec.rb
+3
-3
No files found.
app/services/snippets/create_service.rb
View file @
7b6128a0
...
@@ -56,7 +56,7 @@ module Snippets
...
@@ -56,7 +56,7 @@ module Snippets
snippet_saved
snippet_saved
rescue
=>
e
# Rescuing all because we can receive Creation exceptions, GRPC exceptions, Git exceptions, ...
rescue
=>
e
# Rescuing all because we can receive Creation exceptions, GRPC exceptions, Git exceptions, ...
log_error
(
e
.
message
)
Gitlab
::
ErrorTracking
.
log_exception
(
e
,
service:
'Snippets::CreateService'
)
# If the commit action failed we need to remove the repository if exists
# If the commit action failed we need to remove the repository if exists
delete_repository
(
@snippet
)
if
@snippet
.
repository_exists?
delete_repository
(
@snippet
)
if
@snippet
.
repository_exists?
...
...
app/services/snippets/update_service.rb
View file @
7b6128a0
...
@@ -74,7 +74,7 @@ module Snippets
...
@@ -74,7 +74,7 @@ module Snippets
add_snippet_repository_error
(
snippet:
snippet
,
error:
e
)
add_snippet_repository_error
(
snippet:
snippet
,
error:
e
)
log_error
(
e
.
message
)
Gitlab
::
ErrorTracking
.
log_exception
(
e
,
service:
'Snippets::UpdateService'
)
# If the commit action failed we remove it because
# If the commit action failed we remove it because
# we don't want to leave empty repositories
# we don't want to leave empty repositories
...
...
spec/services/snippets/create_service_spec.rb
View file @
7b6128a0
...
@@ -147,9 +147,11 @@ RSpec.describe Snippets::CreateService do
...
@@ -147,9 +147,11 @@ RSpec.describe Snippets::CreateService do
end
end
context
'when the commit action fails'
do
context
'when the commit action fails'
do
let
(
:error
)
{
SnippetRepository
::
CommitError
.
new
(
'foobar'
)
}
before
do
before
do
allow_next_instance_of
(
SnippetRepository
)
do
|
instance
|
allow_next_instance_of
(
SnippetRepository
)
do
|
instance
|
allow
(
instance
).
to
receive
(
:multi_files_action
).
and_raise
(
SnippetRepository
::
CommitError
.
new
(
'foobar'
)
)
allow
(
instance
).
to
receive
(
:multi_files_action
).
and_raise
(
error
)
end
end
end
end
...
@@ -172,7 +174,7 @@ RSpec.describe Snippets::CreateService do
...
@@ -172,7 +174,7 @@ RSpec.describe Snippets::CreateService do
end
end
it
'logs the error'
do
it
'logs the error'
do
expect
(
Gitlab
::
AppLogger
).
to
receive
(
:error
).
with
(
'foobar
'
)
expect
(
Gitlab
::
ErrorTracking
).
to
receive
(
:log_exception
).
with
(
error
,
service:
'Snippets::CreateService
'
)
subject
subject
end
end
...
...
spec/services/snippets/update_service_spec.rb
View file @
7b6128a0
...
@@ -277,14 +277,14 @@ RSpec.describe Snippets::UpdateService do
...
@@ -277,14 +277,14 @@ RSpec.describe Snippets::UpdateService do
end
end
context
'when an error is raised'
do
context
'when an error is raised'
do
let
(
:error
_message
)
{
'foobar'
}
let
(
:error
)
{
SnippetRepository
::
CommitError
.
new
(
'foobar'
)
}
before
do
before
do
allow
(
snippet
.
snippet_repository
).
to
receive
(
:multi_files_action
).
and_raise
(
SnippetRepository
::
CommitError
,
error_message
)
allow
(
snippet
.
snippet_repository
).
to
receive
(
:multi_files_action
).
and_raise
(
error
)
end
end
it
'logs the error'
do
it
'logs the error'
do
expect
(
Gitlab
::
AppLogger
).
to
receive
(
:error
).
with
(
error_message
)
expect
(
Gitlab
::
ErrorTracking
).
to
receive
(
:log_exception
).
with
(
error
,
service:
'Snippets::UpdateService'
)
subject
subject
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