diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2012-11-27 09:31:15 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2012-11-27 09:31:15 +0300 |
commit | f5551efdfd71c6aedb609093374a6c4dbed6a78b (patch) | |
tree | 226bcf5561a02cea3c1b95339f7063a389cb7bf4 /lib | |
parent | 70bf7f6e191c0e99ad03e1eec2ecbe2aae53fa09 (diff) | |
download | gitlab-ce-f5551efdfd71c6aedb609093374a6c4dbed6a78b.tar.gz |
Rewrite and improve git backend logic. Fix project movind. Raise exception to prevent unexpected issues
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/backend/gitolite.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/backend/gitolite_config.rb | 8 | ||||
-rw-r--r-- | lib/gitlab/project_mover.rb | 4 |
3 files changed, 9 insertions, 5 deletions
diff --git a/lib/gitlab/backend/gitolite.rb b/lib/gitlab/backend/gitolite.rb index 79fe150c19c..05a54ac61e2 100644 --- a/lib/gitlab/backend/gitolite.rb +++ b/lib/gitlab/backend/gitolite.rb @@ -23,7 +23,7 @@ module Gitlab end def update_repository project - config.update_project!(project.path, project) + config.update_project!(project) end def move_repository(old_repo, new_repo, project) diff --git a/lib/gitlab/backend/gitolite_config.rb b/lib/gitlab/backend/gitolite_config.rb index c000aab0aa9..70ccc4782c6 100644 --- a/lib/gitlab/backend/gitolite_config.rb +++ b/lib/gitlab/backend/gitolite_config.rb @@ -109,18 +109,18 @@ module Gitlab end # update or create - def update_project(repo_name, project) + def update_project(project) repo = update_project_config(project, conf) conf.add_repo(repo, true) end - def update_project!(repo_name, project) + def update_project!( project) apply do |config| - config.update_project(repo_name, project) + config.update_project(project) end end - # Updates many projects and uses project.path as the repo path + # Updates many projects and uses project.path_with_namespace as the repo path # An order of magnitude faster than update_project def update_projects(projects) projects.each do |project| diff --git a/lib/gitlab/project_mover.rb b/lib/gitlab/project_mover.rb index 4b23a5461f4..31ede063719 100644 --- a/lib/gitlab/project_mover.rb +++ b/lib/gitlab/project_mover.rb @@ -21,6 +21,10 @@ module Gitlab old_path = File.join(Gitlab.config.git_base_path, old_dir, "#{project.path}.git") new_path = File.join(new_dir_path, "#{project.path}.git") + if File.exists? new_path + raise ProjectMoveError.new("Destination #{new_path} already exists") + end + if system("mv #{old_path} #{new_path}") log_info "Project #{project.name} was moved from #{old_path} to #{new_path}" true |