Skip to content
Snippets Groups Projects

4 0 stable

Closed gitlab-qa-bot requested to merge 4-0-stable into master
21 files
+ 430
209
Compare changes
  • Side-by-side
  • Inline
Files
21
+ 22
2
@@ -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
@@ -48,8 +51,17 @@ class Namespace < ActiveRecord::Base
end
def ensure_dir_exist
namespace_dir_path = File.join(Gitlab.config.gitolite.repos_path, path)
system("mkdir -m 770 #{namespace_dir_path}") unless File.exists?(namespace_dir_path)
unless dir_exists?
system("mkdir -m 770 #{namespace_full_path}")
end
end
def dir_exists?
File.exists?(namespace_full_path)
end
def namespace_full_path
@namespace_full_path ||= File.join(Gitlab.config.gitolite.repos_path, path)
end
def move_dir
@@ -62,10 +74,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