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 | namespace :gitlab do | 1 | namespace :gitlab do |
2 | desc "GITLAB | Enable usernames and namespaces for user projects" | 2 | desc "GITLAB | Enable usernames and namespaces for user projects" |
3 | task enable_namespaces: :environment do | 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 | User.find_each(batch_size: 500) do |user| | 8 | User.find_each(batch_size: 500) do |user| |
7 | next if user.namespace | 9 | next if user.namespace |
@@ -16,7 +18,8 @@ namespace :gitlab do | @@ -16,7 +18,8 @@ namespace :gitlab do | ||
16 | end | 18 | end |
17 | end | 19 | end |
18 | 20 | ||
19 | - print "\n\nDirs for groups:".yellow | 21 | + puts "" |
22 | + print "Create directories for groups: " | ||
20 | 23 | ||
21 | Group.find_each(batch_size: 500) do |group| | 24 | Group.find_each(batch_size: 500) do |group| |
22 | if group.ensure_dir_exist | 25 | if group.ensure_dir_exist |
@@ -25,43 +28,44 @@ namespace :gitlab do | @@ -25,43 +28,44 @@ namespace :gitlab do | ||
25 | print 'F'.red | 28 | print 'F'.red |
26 | end | 29 | end |
27 | end | 30 | end |
31 | + puts "" | ||
28 | 32 | ||
29 | - print "\n\nMove projects from groups under groups dirs:".yellow | ||
30 | git_path = Gitlab.config.gitolite.repos_path | 33 | git_path = Gitlab.config.gitolite.repos_path |
31 | - | 34 | + puts "" |
35 | + puts "Move projects in groups into respective directories ... " | ||
32 | Project.where('namespace_id IS NOT NULL').find_each(batch_size: 500) do |project| | 36 | Project.where('namespace_id IS NOT NULL').find_each(batch_size: 500) do |project| |
33 | next unless project.group | 37 | next unless project.group |
34 | 38 | ||
35 | group = project.group | 39 | group = project.group |
36 | 40 | ||
37 | - puts "\n" | ||
38 | - print " * #{project.name}: " | 41 | + print "#{project.name_with_namespace.yellow} ... " |
39 | 42 | ||
40 | new_path = File.join(git_path, project.path_with_namespace + '.git') | 43 | new_path = File.join(git_path, project.path_with_namespace + '.git') |
41 | 44 | ||
42 | if File.exists?(new_path) | 45 | if File.exists?(new_path) |
43 | - print "ok. already at #{new_path}".cyan | 46 | + puts "already at #{new_path}".green |
44 | next | 47 | next |
45 | end | 48 | end |
46 | 49 | ||
47 | old_path = File.join(git_path, project.path + '.git') | 50 | old_path = File.join(git_path, project.path + '.git') |
48 | 51 | ||
49 | unless File.exists?(old_path) | 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 | next | 54 | next |
52 | end | 55 | end |
53 | 56 | ||
54 | begin | 57 | begin |
55 | Gitlab::ProjectMover.new(project, '', group.path).execute | 58 | Gitlab::ProjectMover.new(project, '', group.path).execute |
56 | - print "ok. Moved to #{new_path}".green | 59 | + puts "moved to #{new_path}".green |
57 | rescue | 60 | rescue |
58 | - print "Failed moving to #{new_path}".red | 61 | + puts "failed moving to #{new_path}".red |
59 | end | 62 | end |
60 | end | 63 | end |
61 | 64 | ||
62 | - print "\n\nRebuild gitolite:".yellow | 65 | + puts "" |
66 | + puts "Rebuild Gitolite ... " | ||
63 | gitolite = Gitlab::Gitolite.new | 67 | gitolite = Gitlab::Gitolite.new |
64 | gitolite.update_repositories(Project.where('namespace_id IS NOT NULL')) | 68 | gitolite.update_repositories(Project.where('namespace_id IS NOT NULL')) |
65 | - puts "\n" | 69 | + puts "... #{"done".green}" |
66 | end | 70 | end |
67 | end | 71 | end |