Commit 31e0fa6572848ee12c05e4e7471c1b3cee426f5f
1 parent
1b6c28b9
Exists in
master
and in
4 other branches
Update output of gitlab:enable_namespaces
Showing
1 changed file
with
16 additions
and
12 deletions
Show diff stats
lib/tasks/gitlab/enable_namespaces.rake
1 | 1 | namespace :gitlab do |
2 | 2 | desc "GITLAB | Enable usernames and namespaces for user projects" |
3 | 3 | task enable_namespaces: :environment do |
4 | - print "\nUsernames for users:".yellow | |
4 | + warn_user_is_not_gitlab | |
5 | + | |
6 | + print "Generate usernames for users without one: " | |
5 | 7 | |
6 | 8 | User.find_each(batch_size: 500) do |user| |
7 | 9 | next if user.namespace |
... | ... | @@ -16,7 +18,8 @@ namespace :gitlab do |
16 | 18 | end |
17 | 19 | end |
18 | 20 | |
19 | - print "\n\nDirs for groups:".yellow | |
21 | + puts "" | |
22 | + print "Create directories for groups: " | |
20 | 23 | |
21 | 24 | Group.find_each(batch_size: 500) do |group| |
22 | 25 | if group.ensure_dir_exist |
... | ... | @@ -25,43 +28,44 @@ namespace :gitlab do |
25 | 28 | print 'F'.red |
26 | 29 | end |
27 | 30 | end |
31 | + puts "" | |
28 | 32 | |
29 | - print "\n\nMove projects from groups under groups dirs:".yellow | |
30 | 33 | git_path = Gitlab.config.gitolite.repos_path |
31 | - | |
34 | + puts "" | |
35 | + puts "Move projects in groups into respective directories ... " | |
32 | 36 | Project.where('namespace_id IS NOT NULL').find_each(batch_size: 500) do |project| |
33 | 37 | next unless project.group |
34 | 38 | |
35 | 39 | group = project.group |
36 | 40 | |
37 | - puts "\n" | |
38 | - print " * #{project.name}: " | |
41 | + print "#{project.name_with_namespace.yellow} ... " | |
39 | 42 | |
40 | 43 | new_path = File.join(git_path, project.path_with_namespace + '.git') |
41 | 44 | |
42 | 45 | if File.exists?(new_path) |
43 | - print "ok. already at #{new_path}".cyan | |
46 | + puts "already at #{new_path}".green | |
44 | 47 | next |
45 | 48 | end |
46 | 49 | |
47 | 50 | old_path = File.join(git_path, project.path + '.git') |
48 | 51 | |
49 | 52 | unless File.exists?(old_path) |
50 | - print "missing. not found at #{old_path}".red | |
53 | + puts "couldn't find it at #{old_path}".red | |
51 | 54 | next |
52 | 55 | end |
53 | 56 | |
54 | 57 | begin |
55 | 58 | Gitlab::ProjectMover.new(project, '', group.path).execute |
56 | - print "ok. Moved to #{new_path}".green | |
59 | + puts "moved to #{new_path}".green | |
57 | 60 | rescue |
58 | - print "Failed moving to #{new_path}".red | |
61 | + puts "failed moving to #{new_path}".red | |
59 | 62 | end |
60 | 63 | end |
61 | 64 | |
62 | - print "\n\nRebuild gitolite:".yellow | |
65 | + puts "" | |
66 | + puts "Rebuild Gitolite ... " | |
63 | 67 | gitolite = Gitlab::Gitolite.new |
64 | 68 | gitolite.update_repositories(Project.where('namespace_id IS NOT NULL')) |
65 | - puts "\n" | |
69 | + puts "... #{"done".green}" | |
66 | 70 | end |
67 | 71 | end | ... | ... |