Commit ff35b37fd2df3b4bdcb9f1b7448d98df07237d08
1 parent
1fb99264
Exists in
master
and in
4 other branches
transfer also wiki repository when transfer a project
Showing
1 changed file
with
8 additions
and
2 deletions
Show diff stats
app/services/project_transfer_service.rb
| ... | ... | @@ -5,6 +5,8 @@ |
| 5 | 5 | class ProjectTransferService |
| 6 | 6 | include Gitlab::ShellAdapter |
| 7 | 7 | |
| 8 | + class TransferError < StandardError; end | |
| 9 | + | |
| 8 | 10 | attr_accessor :project |
| 9 | 11 | |
| 10 | 12 | def transfer(project, new_namespace) |
| ... | ... | @@ -19,14 +21,18 @@ class ProjectTransferService |
| 19 | 21 | project.namespace = new_namespace |
| 20 | 22 | project.save! |
| 21 | 23 | |
| 24 | + # Move main repository | |
| 22 | 25 | unless gitlab_shell.mv_repository(old_path, new_path) |
| 23 | 26 | raise TransferError.new('Cannot move project') |
| 24 | 27 | end |
| 25 | 28 | |
| 29 | + # Move wiki repo also if present | |
| 30 | + if project.wikis.any? | |
| 31 | + gitlab_shell.mv_repository("#{old_path}.wiki", "#{new_path}.wiki") | |
| 32 | + end | |
| 33 | + | |
| 26 | 34 | true |
| 27 | 35 | end |
| 28 | - rescue => ex | |
| 29 | - raise Project::TransferError.new(ex.message) | |
| 30 | 36 | end |
| 31 | 37 | end |
| 32 | 38 | ... | ... |