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
7322476e
Commit
7322476e
authored
May 06, 2020
by
James Fargher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stop using BaseService
Refactor to use ServiceResponse
parent
79b62b32
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
16 deletions
+18
-16
app/services/projects/update_repository_storage_service.rb
app/services/projects/update_repository_storage_service.rb
+7
-5
spec/services/projects/update_repository_storage_service_spec.rb
...rvices/projects/update_repository_storage_service_spec.rb
+6
-6
spec/support/shared_examples/services/projects/update_repository_storage_service_shared_examples.rb
...ects/update_repository_storage_service_shared_examples.rb
+5
-5
No files found.
app/services/projects/update_repository_storage_service.rb
View file @
7322476e
# frozen_string_literal: true
module
Projects
class
UpdateRepositoryStorageService
<
BaseService
class
UpdateRepositoryStorageService
Error
=
Class
.
new
(
StandardError
)
SameFilesystemError
=
Class
.
new
(
Error
)
attr_reader
:repository_storage_move
delegate
:destination_storage_name
,
to: :repository_storage_move
delegate
:project
,
:destination_storage_name
,
to: :repository_storage_move
delegate
:repository
,
to: :project
def
initialize
(
repository_storage_move
)
super
(
repository_storage_move
.
project
)
@repository_storage_move
=
repository_storage_move
end
...
...
@@ -31,7 +31,7 @@ module Projects
enqueue_housekeeping
success
ServiceResponse
.
success
rescue
StandardError
=>
e
project
.
transaction
do
...
...
@@ -41,7 +41,9 @@ module Projects
Gitlab
::
ErrorTracking
.
track_exception
(
e
,
project_path:
project
.
full_path
)
error
(
s_
(
"UpdateRepositoryStorage|Error moving repository storage for %{project_full_path} - %{message}"
)
%
{
project_full_path:
project
.
full_path
,
message:
e
.
message
})
ServiceResponse
.
error
(
message:
s_
(
"UpdateRepositoryStorage|Error moving repository storage for %{project_full_path} - %{message}"
)
%
{
project_full_path:
project
.
full_path
,
message:
e
.
message
}
)
end
private
...
...
spec/services/projects/update_repository_storage_service_spec.rb
View file @
7322476e
...
...
@@ -46,7 +46,7 @@ describe Projects::UpdateRepositoryStorageService do
result
=
subject
.
execute
expect
(
result
[
:status
]).
to
eq
(
:success
)
expect
(
result
).
to
be_success
expect
(
project
).
not_to
be_repository_read_only
expect
(
project
.
repository_storage
).
to
eq
(
'test_second_storage'
)
expect
(
gitlab_shell
.
repository_exists?
(
'default'
,
old_path
)).
to
be
(
false
)
...
...
@@ -60,8 +60,8 @@ describe Projects::UpdateRepositoryStorageService do
it
'bails out and does nothing'
do
result
=
subject
.
execute
expect
(
result
[
:status
]).
to
eq
(
:error
)
expect
(
result
[
:message
]
).
to
match
(
/SameFilesystemError/
)
expect
(
result
).
to
be_error
expect
(
result
.
message
).
to
match
(
/SameFilesystemError/
)
end
end
...
...
@@ -79,7 +79,7 @@ describe Projects::UpdateRepositoryStorageService do
result
=
subject
.
execute
expect
(
result
[
:status
]).
to
eq
(
:error
)
expect
(
result
).
to
be_error
expect
(
project
).
not_to
be_repository_read_only
expect
(
project
.
repository_storage
).
to
eq
(
'default'
)
end
...
...
@@ -100,7 +100,7 @@ describe Projects::UpdateRepositoryStorageService do
result
=
subject
.
execute
expect
(
result
[
:status
]).
to
eq
(
:error
)
expect
(
result
).
to
be_error
expect
(
project
).
not_to
be_repository_read_only
expect
(
project
.
repository_storage
).
to
eq
(
'default'
)
end
...
...
@@ -122,7 +122,7 @@ describe Projects::UpdateRepositoryStorageService do
result
=
subject
.
execute
expect
(
result
[
:status
]).
to
eq
(
:success
)
expect
(
result
).
to
be_success
expect
(
project
.
repository_storage
).
to
eq
(
'test_second_storage'
)
expect
(
project
.
reload_pool_repository
).
to
be_nil
end
...
...
spec/support/shared_examples/services/projects/update_repository_storage_service_shared_examples.rb
View file @
7322476e
...
...
@@ -49,7 +49,7 @@ RSpec.shared_examples 'moves repository to another storage' do |repository_type|
result
=
subject
.
execute
expect
(
result
[
:status
]).
to
eq
(
:success
)
expect
(
result
).
to
be_success
expect
(
project
).
not_to
be_repository_read_only
expect
(
project
.
repository_storage
).
to
eq
(
'test_second_storage'
)
expect
(
gitlab_shell
.
repository_exists?
(
'default'
,
old_project_repository_path
)).
to
be
(
false
)
...
...
@@ -92,8 +92,8 @@ RSpec.shared_examples 'moves repository to another storage' do |repository_type|
it
'bails out and does nothing'
do
result
=
subject
.
execute
expect
(
result
[
:status
]).
to
eq
(
:error
)
expect
(
result
[
:message
]
).
to
match
(
/SameFilesystemError/
)
expect
(
result
).
to
be_error
expect
(
result
.
message
).
to
match
(
/SameFilesystemError/
)
end
end
...
...
@@ -118,7 +118,7 @@ RSpec.shared_examples 'moves repository to another storage' do |repository_type|
result
=
subject
.
execute
expect
(
result
[
:status
]).
to
eq
(
:error
)
expect
(
result
).
to
be_error
expect
(
project
).
not_to
be_repository_read_only
expect
(
project
.
repository_storage
).
to
eq
(
'default'
)
end
...
...
@@ -146,7 +146,7 @@ RSpec.shared_examples 'moves repository to another storage' do |repository_type|
result
=
subject
.
execute
expect
(
result
[
:status
]).
to
eq
(
:error
)
expect
(
result
).
to
be_error
expect
(
project
).
not_to
be_repository_read_only
expect
(
project
.
repository_storage
).
to
eq
(
'default'
)
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