transfer also wiki repository when transfer a project

This commit is contained in:
Dmitriy Zaporozhets 2013-03-25 10:47:47 +02:00
parent 1fb99264a9
commit ff35b37fd2

View file

@ -5,6 +5,8 @@
class ProjectTransferService class ProjectTransferService
include Gitlab::ShellAdapter include Gitlab::ShellAdapter
class TransferError < StandardError; end
attr_accessor :project attr_accessor :project
def transfer(project, new_namespace) def transfer(project, new_namespace)
@ -19,14 +21,18 @@ class ProjectTransferService
project.namespace = new_namespace project.namespace = new_namespace
project.save! project.save!
# Move main repository
unless gitlab_shell.mv_repository(old_path, new_path) unless gitlab_shell.mv_repository(old_path, new_path)
raise TransferError.new('Cannot move project') raise TransferError.new('Cannot move project')
end end
# Move wiki repo also if present
if project.wikis.any?
gitlab_shell.mv_repository("#{old_path}.wiki", "#{new_path}.wiki")
end
true true
end end
rescue => ex
raise Project::TransferError.new(ex.message)
end end
end end