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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
cf8b465c
Commit
cf8b465c
authored
Jun 19, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove Global namespace from options. Prepared file for migration of global projects
parent
6e35acef
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
17 additions
and
16 deletions
+17
-16
app/contexts/projects/create_context.rb
app/contexts/projects/create_context.rb
+3
-7
app/contexts/projects/transfer_context.rb
app/contexts/projects/transfer_context.rb
+1
-6
app/controllers/admin/projects_controller.rb
app/controllers/admin/projects_controller.rb
+0
-1
app/helpers/namespaces_helper.rb
app/helpers/namespaces_helper.rb
+0
-1
app/views/projects/edit.html.haml
app/views/projects/edit.html.haml
+1
-1
lib/tasks/migrate/migrate_global_projects.rake
lib/tasks/migrate/migrate_global_projects.rake
+12
-0
No files found.
app/contexts/projects/create_context.rb
View file @
cf8b465c
...
...
@@ -33,7 +33,7 @@ module Projects
# Find matching namespace and check if it allowed
# for current user if namespace_id passed.
if
allowed_namespace?
(
current_user
,
namespace_id
)
@project
.
namespace_id
=
namespace_id
unless
namespace_id
==
Namespace
.
global_id
@project
.
namespace_id
=
namespace_id
else
deny_namespace
return
@project
...
...
@@ -75,12 +75,8 @@ module Projects
end
def
allowed_namespace?
(
user
,
namespace_id
)
if
namespace_id
==
Namespace
.
global_id
return
user
.
admin
else
namespace
=
Namespace
.
find_by_id
(
namespace_id
)
current_user
.
can?
(
:manage_namespace
,
namespace
)
end
namespace
=
Namespace
.
find_by_id
(
namespace_id
)
current_user
.
can?
(
:manage_namespace
,
namespace
)
end
end
end
app/contexts/projects/transfer_context.rb
View file @
cf8b465c
...
...
@@ -5,12 +5,7 @@ module Projects
allowed_transfer
=
can?
(
current_user
,
:change_namespace
,
project
)
||
role
==
:admin
if
allowed_transfer
&&
namespace_id
.
present?
if
namespace_id
==
Namespace
.
global_id
if
project
.
namespace
.
present?
# Transfer to global namespace from anyone
project
.
transfer
(
nil
)
end
elsif
namespace_id
.
to_i
!=
project
.
namespace_id
if
namespace_id
.
to_i
!=
project
.
namespace_id
# Transfer to someone namespace
namespace
=
Namespace
.
find
(
namespace_id
)
project
.
transfer
(
namespace
)
...
...
app/controllers/admin/projects_controller.rb
View file @
cf8b465c
...
...
@@ -9,7 +9,6 @@ class Admin::ProjectsController < Admin::ApplicationController
@projects
=
@projects
.
where
(
public:
true
)
if
params
[
:public_only
].
present?
@projects
=
@projects
.
with_push
if
params
[
:with_push
].
present?
@projects
=
@projects
.
abandoned
if
params
[
:abandoned
].
present?
@projects
=
@projects
.
where
(
namespace_id:
nil
)
if
params
[
:namespace_id
]
==
Namespace
.
global_id
@projects
=
@projects
.
search
(
params
[
:name
])
if
params
[
:name
].
present?
@projects
=
@projects
.
includes
(
:namespace
).
order
(
"namespaces.path, projects.name ASC"
).
page
(
params
[
:page
]).
per
(
20
)
end
...
...
app/helpers/namespaces_helper.rb
View file @
cf8b465c
...
...
@@ -3,7 +3,6 @@ module NamespacesHelper
groups
=
current_user
.
owned_groups
.
select
{
|
n
|
n
.
type
==
'Group'
}
users
=
current_user
.
namespaces
.
reject
{
|
n
|
n
.
type
==
'Group'
}
global_opts
=
[
"Global"
,
[[
'/'
,
Namespace
.
global_id
]]
]
group_opts
=
[
"Groups"
,
groups
.
sort_by
(
&
:human_name
).
map
{
|
g
|
[
g
.
human_name
,
g
.
id
]}
]
users_opts
=
[
"Users"
,
users
.
sort_by
(
&
:human_name
).
map
{
|
u
|
[
u
.
human_name
,
u
.
id
]}
]
...
...
app/views/projects/edit.html.haml
View file @
cf8b465c
...
...
@@ -129,7 +129,7 @@
%span
Namespace
.controls
.clearfix
=
f
.
select
:namespace_id
,
namespaces_options
(
@project
.
namespace_id
||
Namespace
::
global_id
),
{
prompt:
'Choose a project namespace'
},
{
class:
'chosen'
}
=
f
.
select
:namespace_id
,
namespaces_options
(
@project
.
namespace_id
),
{
prompt:
'Choose a project namespace'
},
{
class:
'chosen'
}
%ul
%li
Be careful. Changing project namespace can have unintended side effects
%li
You can transfer project only to namespaces you can manage
...
...
lib/tasks/migrate/migrate_global_projects.rake
0 → 100644
View file @
cf8b465c
desc
"GITLAB | Migrate Global Projects to Namespaces"
task
migrate_global_projects: :environment
do
puts
"This will move all projects without namespace to owner namespace"
ask_to_continue
Project
.
where
(
namespace_id:
nil
).
find_each
(
batch_size:
20
)
do
|
project
|
# TODO: transfer code here
print
'.'
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