summaryrefslogtreecommitdiff
path: root/lib/tasks
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-11-25 18:24:27 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-11-25 18:24:27 +0200
commit04b51a2b892c9c675f638239a3fbfec39cdc4729 (patch)
treea5ca7bdabc3b62c776e0a67d22120ffdf32fe657 /lib/tasks
parentfbe03c506ff5e5714f4feacc33e42c5d4931dbbc (diff)
downloadgitlab-ce-04b51a2b892c9c675f638239a3fbfec39cdc4729.tar.gz
Improve activate_namespace task to build missing dirs and moving repos correctly
Diffstat (limited to 'lib/tasks')
-rw-r--r--lib/tasks/gitlab/activate_namespaces.rake32
1 files changed, 28 insertions, 4 deletions
diff --git a/lib/tasks/gitlab/activate_namespaces.rake b/lib/tasks/gitlab/activate_namespaces.rake
index 718c2ff2a6e..637964e151c 100644
--- a/lib/tasks/gitlab/activate_namespaces.rake
+++ b/lib/tasks/gitlab/activate_namespaces.rake
@@ -1,6 +1,8 @@
namespace :gitlab do
desc "GITLAB | Enable usernames and namespaces for user projects"
task activate_namespaces: :environment do
+ print "\nUsernames for users:".yellow
+
User.find_each(batch_size: 500) do |user|
next if user.namespace
@@ -14,6 +16,8 @@ namespace :gitlab do
end
end
+ print "\n\nDirs for groups:".yellow
+
Group.find_each(batch_size: 500) do |group|
if group.ensure_dir_exist
print '.'.green
@@ -22,23 +26,43 @@ namespace :gitlab do
end
end
+ print "\n\nMove projects from groups under groups dirs:".yellow
git_path = Gitlab.config.git_base_path
Project.where('namespace_id IS NOT NULL').find_each(batch_size: 500) do |project|
next unless project.group
+ next if project.empty_repo?
group = project.group
- next if File.exists?(File.join(git_path, project.path_with_namespace))
+ puts "\n"
+ print " * #{project.name}: "
+
+ new_path = File.join(git_path, project.path_with_namespace + '.git')
+
+ if File.exists?(new_path)
+ print "ok. already at #{new_path}".cyan
+ next
+ end
+
+ old_path = File.join(git_path, project.path + '.git')
- next unless File.exists?(File.join(git_path, project.path))
+ unless File.exists?(old_path)
+ print "missing. not found at #{old_path}".red
+ next
+ end
begin
Gitlab::ProjectMover.new(project, '', group.path).execute
- print '.'.green
+ print "ok. Moved to #{new_path}".green
rescue
- print 'F'.red
+ print "Failed moving to #{new_path}".red
end
end
+
+ print "\n\nRebuild gitolite:".yellow
+ gitolite = Gitlab::Gitolite.new
+ gitolite.update_repositories(Project.where('namespace_id IS NOT NULL'))
+ puts "\n"
end
end