Create namespace on username init. Raise exception if project cannot be moved
This commit is contained in:
parent
4023d9f852
commit
d405c8fc60
4 changed files with 21 additions and 8 deletions
|
@ -1,7 +1,5 @@
|
|||
class ProjectObserver < ActiveRecord::Observer
|
||||
def after_save(project)
|
||||
project.update_repository
|
||||
|
||||
# Move repository if namespace changed
|
||||
if project.namespace_id_changed? and not project.new_record?
|
||||
old_dir = Namespace.find_by_id(project.namespace_id_was).try(:path) || ''
|
||||
|
@ -9,6 +7,9 @@ class ProjectObserver < ActiveRecord::Observer
|
|||
|
||||
Gitlab::ProjectMover.new(project, old_dir, new_dir).execute
|
||||
end
|
||||
|
||||
# Update gitolite
|
||||
project.update_repository
|
||||
end
|
||||
|
||||
def after_destroy(project)
|
||||
|
|
|
@ -12,8 +12,12 @@ class UserObserver < ActiveRecord::Observer
|
|||
end
|
||||
|
||||
def after_save user
|
||||
if user.username_changed? and user.namespace
|
||||
user.namespace.update_attributes(path: user.username)
|
||||
if user.username_changed?
|
||||
if user.namespace
|
||||
user.namespace.update_attributes(path: user.username)
|
||||
else
|
||||
user.create_namespace!(path: user.username, name: user.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue