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
7b5389ec
Commit
7b5389ec
authored
Mar 03, 2017
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix broken Geo::MoveRepositoryService and add spec
Closes #1826
parent
dc02c5da
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
3 deletions
+27
-3
app/services/geo/move_repository_service.rb
app/services/geo/move_repository_service.rb
+7
-3
spec/services/geo/move_repository_service_spec.rb
spec/services/geo/move_repository_service_spec.rb
+20
-0
No files found.
app/services/geo/move_repository_service.rb
View file @
7b5389ec
...
...
@@ -16,14 +16,16 @@ module Geo
project
.
expire_caches_before_rename
(
old_path_with_namespace
)
# Make sure target directory exists (used when transfering repositories)
project
.
namespace
.
ensure_dir_exist
project
.
ensure_dir_exist
if
gitlab_shell
.
mv_repository
(
old_path_with_namespace
,
new_path_with_namespace
)
if
gitlab_shell
.
mv_repository
(
project
.
repository_storage_path
,
old_path_with_namespace
,
new_path_with_namespace
)
# If repository moved successfully we need to send update instructions to users.
# However we cannot allow rollback since we moved repository
# So we basically we mute exceptions in next actions
begin
gitlab_shell
.
mv_repository
(
"
#{
old_path_with_namespace
}
.wiki"
,
"
#{
new_path_with_namespace
}
.wiki"
)
gitlab_shell
.
mv_repository
(
project
.
repository_storage_path
,
"
#{
old_path_with_namespace
}
.wiki"
,
"
#{
new_path_with_namespace
}
.wiki"
)
rescue
# Returning false does not rollback after_* transaction but gives
# us information about failing some of tasks
...
...
@@ -34,6 +36,8 @@ module Geo
# db changes in order to prevent out of sync between db and fs
raise
Exception
.
new
(
'repository cannot be renamed'
)
end
true
end
end
end
spec/services/geo/move_repository_service_spec.rb
0 → 100644
View file @
7b5389ec
require
'spec_helper'
describe
Geo
::
MoveRepositoryService
,
services:
true
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:new_path
)
{
project
.
path_with_namespace
+
'+renamed'
}
let
(
:full_new_path
)
{
File
.
join
(
project
.
repository_storage_path
,
new_path
)
}
subject
{
Geo
::
MoveRepositoryService
.
new
(
project
.
id
,
project
.
name
,
project
.
path_with_namespace
,
new_path
)
}
describe
'#execute'
do
it
'renames the path'
do
old_path
=
project
.
repository
.
path_to_repo
expect
(
File
.
directory?
(
old_path
)).
to
be_truthy
expect
(
subject
.
execute
).
to
eq
(
true
)
expect
(
File
.
directory?
(
old_path
)).
to
be_falsey
expect
(
File
.
directory?
(
"
#{
full_new_path
}
.git"
)).
to
be_truthy
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