summaryrefslogtreecommitdiff
path: root/lib/tasks/gitlab/activate_namespaces.rake
blob: bfab46f66a4ff0c1a1fea518b7eb850463b94608 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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]
        if user.update_attributes!(username: username)
          print '.'.green
        else
          print 'F'.red
        end
      end
    end
  end
end