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
5fa4b5dc
Commit
5fa4b5dc
authored
Mar 21, 2020
by
Francisco Javier López
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move repository creation outside snippet db transaction
parent
9ce3beb3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
10 deletions
+13
-10
app/services/snippets/create_service.rb
app/services/snippets/create_service.rb
+7
-10
spec/services/snippets/create_service_spec.rb
spec/services/snippets/create_service_spec.rb
+6
-0
No files found.
app/services/snippets/create_service.rb
View file @
5fa4b5dc
...
...
@@ -38,19 +38,16 @@ module Snippets
private
def
save_and_commit
(
snippet
)
result
=
snippet
.
with_transaction_returning_status
do
(
snippet
.
save
&&
snippet
.
store_mentions!
).
tap
do
|
saved
|
break
false
unless
save
d
snippet_saved
=
snippet
.
with_transaction_returning_status
do
snippet
.
save
&&
snippet
.
store_mentions!
en
d
if
Feature
.
enabled?
(
:version_snippets
,
current_user
)
if
snippet_saved
&&
Feature
.
enabled?
(
:version_snippets
,
current_user
)
create_repository_for
(
snippet
)
create_commit
(
snippet
)
end
end
end
create_commit
(
snippet
)
if
result
&&
snippet
.
repository_exists?
result
snippet_saved
rescue
=>
e
# Rescuing all because we can receive Creation exceptions, GRPC exceptions, Git exceptions, ...
snippet
.
errors
.
add
(
:base
,
e
.
message
)
...
...
spec/services/snippets/create_service_spec.rb
View file @
5fa4b5dc
...
...
@@ -193,6 +193,12 @@ describe Snippets::CreateService do
subject
end
it
'destroys the snippet_repository'
do
subject
expect
(
SnippetRepository
.
count
).
to
be_zero
end
it
'returns the error'
do
response
=
subject
...
...
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