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
Tatuya Kamada
gitlab-ce
Commits
f9979476
Commit
f9979476
authored
Nov 24, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Project can be transfered to namespace and out now
parent
d405c8fc
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
13 deletions
+16
-13
app/controllers/admin/groups_controller.rb
app/controllers/admin/groups_controller.rb
+2
-4
app/models/project.rb
app/models/project.rb
+14
-0
app/observers/project_observer.rb
app/observers/project_observer.rb
+0
-9
No files found.
app/controllers/admin/groups_controller.rb
View file @
f9979476
...
@@ -50,8 +50,7 @@ class Admin::GroupsController < AdminController
...
@@ -50,8 +50,7 @@ class Admin::GroupsController < AdminController
project_ids
=
params
[
:project_ids
]
project_ids
=
params
[
:project_ids
]
Project
.
where
(
id:
project_ids
).
each
do
|
project
|
Project
.
where
(
id:
project_ids
).
each
do
|
project
|
project
.
namespace_id
=
@group
.
id
project
.
transfer
(
@group
)
project
.
save
end
end
redirect_to
:back
,
notice:
'Group was successfully updated.'
redirect_to
:back
,
notice:
'Group was successfully updated.'
...
@@ -59,8 +58,7 @@ class Admin::GroupsController < AdminController
...
@@ -59,8 +58,7 @@ class Admin::GroupsController < AdminController
def
remove_project
def
remove_project
@project
=
Project
.
find
(
params
[
:project_id
])
@project
=
Project
.
find
(
params
[
:project_id
])
@project
.
namespace_id
=
nil
@project
.
transfer
(
nil
)
@project
.
save
redirect_to
:back
,
notice:
'Group was successfully updated.'
redirect_to
:back
,
notice:
'Group was successfully updated.'
end
end
...
...
app/models/project.rb
View file @
f9979476
...
@@ -226,4 +226,18 @@ class Project < ActiveRecord::Base
...
@@ -226,4 +226,18 @@ class Project < ActiveRecord::Base
def
code
def
code
path
path
end
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
)
||
''
Gitlab
::
ProjectMover
.
new
(
self
,
old_dir
,
new_dir
).
execute
save!
end
end
end
end
app/observers/project_observer.rb
View file @
f9979476
class
ProjectObserver
<
ActiveRecord
::
Observer
class
ProjectObserver
<
ActiveRecord
::
Observer
def
after_save
(
project
)
def
after_save
(
project
)
# Move repository if namespace changed
if
project
.
namespace_id_changed?
and
not
project
.
new_record?
old_dir
=
Namespace
.
find_by_id
(
project
.
namespace_id_was
).
try
(
:path
)
||
''
new_dir
=
Namespace
.
find_by_id
(
project
.
namespace_id
).
try
(
:path
)
||
''
Gitlab
::
ProjectMover
.
new
(
project
,
old_dir
,
new_dir
).
execute
end
# Update gitolite
project
.
update_repository
project
.
update_repository
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