Create namespace on username init. Raise exception if project cannot be moved
This commit is contained in:
parent
4023d9f852
commit
d405c8fc60
4 changed files with 21 additions and 8 deletions
|
@ -2,11 +2,15 @@ namespace :gitlab do
|
|||
desc "GITLAB | Enable usernames and namespaces for user projects"
|
||||
task activate_namespaces: :environment do
|
||||
User.find_each(batch_size: 500) do |user|
|
||||
next if user.namespace
|
||||
|
||||
User.transaction do
|
||||
username = user.email.match(/^[^@]*/)[0]
|
||||
user.update_attributes!(username: username)
|
||||
user.create_namespace!(code: username, name: user.name)
|
||||
print '.'.green
|
||||
if user.update_attributes!(username: username)
|
||||
print '.'.green
|
||||
else
|
||||
print 'F'.red
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue