summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-11-24 12:25:04 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-11-24 12:25:04 +0200
commitd405c8fc605256c1273cca1e30dfa1196459d625 (patch)
tree10019736af37312b6a7d9bfed0b97115c0ded9bb /lib
parent4023d9f85290faea47a2b2bcf3ce879ed0f07e9f (diff)
downloadgitlab-ce-d405c8fc605256c1273cca1e30dfa1196459d625.tar.gz
Create namespace on username init. Raise exception if project cannot be moved
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/project_mover.rb6
-rw-r--r--lib/tasks/gitlab/activate_namespaces.rake10
2 files changed, 12 insertions, 4 deletions
diff --git a/lib/gitlab/project_mover.rb b/lib/gitlab/project_mover.rb
index 9dc3e019faa..c9f5e822f6a 100644
--- a/lib/gitlab/project_mover.rb
+++ b/lib/gitlab/project_mover.rb
@@ -3,6 +3,8 @@
# Used for moving project repositories from one subdir to another
module Gitlab
class ProjectMover
+ class ProjectMoveError < StandardError; end
+
attr_reader :project, :old_dir, :new_dir
def initialize(project, old_dir, new_dir)
@@ -23,7 +25,9 @@ module Gitlab
log_info "Project #{project.name} was moved from #{old_path} to #{new_path}"
true
else
- log_info "Error! Project #{project.name} cannot be moved from #{old_path} to #{new_path}"
+ message = "Project #{project.name} cannot be moved from #{old_path} to #{new_path}"
+ log_info "Error! #{message}"
+ raise ProjectMoveError.new(message)
false
end
end
diff --git a/lib/tasks/gitlab/activate_namespaces.rake b/lib/tasks/gitlab/activate_namespaces.rake
index 0c7c3e7160e..bfab46f66a4 100644
--- a/lib/tasks/gitlab/activate_namespaces.rake
+++ b/lib/tasks/gitlab/activate_namespaces.rake
@@ -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