Update projects in gitolite after namespace moved. Added rake task to cleanup garbage from gitolite
This commit is contained in:
parent
8ef7b9b6d1
commit
45b6103997
3 changed files with 45 additions and 1 deletions
|
@ -27,10 +27,13 @@ class Namespace < ActiveRecord::Base
|
|||
|
||||
after_create :ensure_dir_exist
|
||||
after_update :move_dir
|
||||
after_commit :update_gitolite, on: :update, if: :require_update_gitolite
|
||||
after_destroy :rm_dir
|
||||
|
||||
scope :root, where('type IS NULL')
|
||||
|
||||
attr_accessor :require_update_gitolite
|
||||
|
||||
def self.search query
|
||||
where("name LIKE :query OR path LIKE :query", query: "%#{query}%")
|
||||
end
|
||||
|
@ -62,10 +65,18 @@ class Namespace < ActiveRecord::Base
|
|||
|
||||
if system("mv #{old_path} #{new_path}")
|
||||
send_update_instructions
|
||||
@require_update_gitolite = true
|
||||
else
|
||||
raise "Namespace move error #{old_path} #{new_path}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def update_gitolite
|
||||
@require_update_gitolite = false
|
||||
projects.each(&:update_repository)
|
||||
end
|
||||
|
||||
def rm_dir
|
||||
dir_path = File.join(Gitlab.config.gitolite.repos_path, path)
|
||||
system("rm -rf #{dir_path}")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue