summaryrefslogtreecommitdiff
path: root/app/models/namespace.rb
diff options
context:
space:
mode:
authorRiyad Preukschas <riyad@informatik.uni-bremen.de>2013-01-15 00:52:25 +0100
committerRiyad Preukschas <riyad@informatik.uni-bremen.de>2013-01-15 00:52:25 +0100
commit30227869482bbbdbfea153f2b45ef3bb9a9fd218 (patch)
treeaff64071116447092751770d2896998f62d1b44a /app/models/namespace.rb
parent8ee5fce9d64b70d8981896457484fae622d142c9 (diff)
parentaca0caa8cc1a6bd481f87dd810284e69d3747050 (diff)
downloadgitlab-ce-30227869482bbbdbfea153f2b45ef3bb9a9fd218.tar.gz
Merge commit 'master' into discussions
Conflicts: app/assets/stylesheets/sections/notes.scss app/contexts/notes/load_context.rb app/models/project.rb app/observers/note_observer.rb app/roles/votes.rb app/views/commit/show.html.haml app/views/merge_requests/_show.html.haml app/views/merge_requests/diffs.js.haml app/views/merge_requests/show.js.haml app/views/notes/_note.html.haml features/steps/project/project_merge_requests.rb spec/models/note_spec.rb
Diffstat (limited to 'app/models/namespace.rb')
-rw-r--r--app/models/namespace.rb31
1 files changed, 26 insertions, 5 deletions
diff --git a/app/models/namespace.rb b/app/models/namespace.rb
index 8c90f5aee26..89c1f9adb5a 100644
--- a/app/models/namespace.rb
+++ b/app/models/namespace.rb
@@ -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?
+ FileUtils.mkdir( namespace_full_path, mode: 0770 )
+ 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
@@ -59,16 +71,25 @@ class Namespace < ActiveRecord::Base
if File.exists?(new_path)
raise "Already exists"
end
-
- if system("mv #{old_path} #{new_path}")
+
+ begin
+ FileUtils.mv( old_path, new_path )
send_update_instructions
+ @require_update_gitolite = true
+ rescue Exception => e
+ 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}")
+ FileUtils.rm_r( dir_path, force: true )
end
def send_update_instructions