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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
cba6e924
Commit
cba6e924
authored
Feb 26, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move transfer logic out of project to service
parent
0cf0487d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
26 deletions
+38
-26
app/models/project.rb
app/models/project.rb
+4
-26
app/services/project_transfer_service.rb
app/services/project_transfer_service.rb
+34
-0
No files found.
app/models/project.rb
View file @
cba6e924
...
...
@@ -247,32 +247,6 @@ class Project < ActiveRecord::Base
users_projects
.
find_by_user_id
(
user_id
)
end
def
transfer
(
new_namespace
)
Project
.
transaction
do
old_namespace
=
namespace
self
.
namespace
=
new_namespace
old_dir
=
old_namespace
.
try
(
:path
)
||
''
new_dir
=
new_namespace
.
try
(
:path
)
||
''
old_repo
=
if
old_dir
.
present?
File
.
join
(
old_dir
,
self
.
path
)
else
self
.
path
end
if
Project
.
where
(
path:
self
.
path
,
namespace_id:
new_namespace
.
try
(
:id
)).
present?
raise
TransferError
.
new
(
"Project with same path in target namespace already exists"
)
end
Gitlab
::
ProjectMover
.
new
(
self
,
old_dir
,
new_dir
).
execute
save!
end
rescue
Gitlab
::
ProjectMover
::
ProjectMoveError
=>
ex
raise
Project
::
TransferError
.
new
(
ex
.
message
)
end
def
name_with_namespace
@name_with_namespace
||=
begin
if
namespace
...
...
@@ -295,6 +269,10 @@ class Project < ActiveRecord::Base
end
end
def
transfer
(
new_namespace
)
ProjectTransferService
.
new
.
transfer
(
self
,
new_namespace
)
end
def
execute_hooks
(
data
)
hooks
.
each
{
|
hook
|
hook
.
async_execute
(
data
)
}
end
...
...
app/services/project_transfer_service.rb
0 → 100644
View file @
cba6e924
# ProjectTransferService class
#
# Used for transfer project to another namespace
#
class
ProjectTransferService
attr_accessor
:project
def
transfer
(
project
,
new_namespace
)
Project
.
transaction
do
old_namespace
=
project
.
namespace
project
.
namespace
=
new_namespace
old_dir
=
old_namespace
.
try
(
:path
)
||
''
new_dir
=
new_namespace
.
try
(
:path
)
||
''
old_repo
=
if
old_dir
.
present?
File
.
join
(
old_dir
,
project
.
path
)
else
project
.
path
end
if
Project
.
where
(
path:
project
.
path
,
namespace_id:
new_namespace
.
try
(
:id
)).
present?
raise
TransferError
.
new
(
"Project with same path in target namespace already exists"
)
end
Gitlab
::
ProjectMover
.
new
(
project
,
old_dir
,
new_dir
).
execute
save!
end
rescue
Gitlab
::
ProjectMover
::
ProjectMoveError
=>
ex
raise
Project
::
TransferError
.
new
(
ex
.
message
)
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