Rename design repository if exists

parent 84276bb7
...@@ -45,6 +45,11 @@ module Geo ...@@ -45,6 +45,11 @@ module Geo
return false return false
end end
if project.design_repository.exists? && !move_design_repository
log_error('Design repository cannot be moved')
return false
end
true true
rescue => ex rescue => ex
log_error('Repository cannot be moved', error: ex) log_error('Repository cannot be moved', error: ex)
...@@ -56,7 +61,35 @@ module Geo ...@@ -56,7 +61,35 @@ module Geo
end end
def move_wiki_repository def move_wiki_repository
gitlab_shell.mv_repository(project.repository_storage, "#{old_disk_path}.wiki", "#{new_disk_path}.wiki") gitlab_shell.mv_repository(project.repository_storage, old_wiki_disk_path, new_wiki_disk_path)
end
def move_design_repository
gitlab_shell.mv_repository(project.repository_storage, old_design_disk_path, new_design_disk_path)
end
def wiki_path_suffix
Gitlab::GlRepository::WIKI.path_suffix
end
def old_wiki_disk_path
"#{old_disk_path}#{wiki_path_suffix}"
end
def new_wiki_disk_path
"#{new_disk_path}#{wiki_path_suffix}"
end
def design_path_suffix
EE::Gitlab::GlRepository::DESIGN.path_suffix
end
def old_design_disk_path
"#{old_disk_path}#{design_path_suffix}"
end
def new_design_disk_path
"#{new_disk_path}#{design_path_suffix}"
end end
end end
end end
...@@ -59,6 +59,30 @@ describe Geo::MoveRepositoryService, :geo do ...@@ -59,6 +59,30 @@ describe Geo::MoveRepositoryService, :geo do
expect(service.execute).to eq false expect(service.execute).to eq false
end end
context 'when design repository exists' do
before do
project.design_repository.create_if_not_exists
end
it 'returns false when design repository can not be renamed' do
allow_any_instance_of(Gitlab::Shell).to receive(:mv_repository)
.with(project.repository_storage, old_path, new_path)
.and_return(true)
allow_any_instance_of(Gitlab::Shell).to receive(:mv_repository)
.with(project.repository_storage, "#{old_path}.wiki", "#{new_path}.wiki")
.and_return(true)
allow_any_instance_of(Gitlab::Shell).to receive(:mv_repository)
.with(project.repository_storage, "#{old_path}.design", "#{new_path}.design")
.and_return(false)
expect(service).to receive(:log_error).with('Design repository cannot be moved')
expect(service.execute).to eq false
end
end
context 'wiki disabled' do context 'wiki disabled' do
let(:project) { create(:project, :repository, :wiki_disabled, :legacy_storage) } let(:project) { create(:project, :repository, :wiki_disabled, :legacy_storage) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment