Rewrite and improve git backend logic. Fix project movind. Raise exception to prevent unexpected issues

This commit is contained in:
Dmitriy Zaporozhets 2012-11-27 09:31:15 +03:00
parent 70bf7f6e19
commit f5551efdfd
20 changed files with 146 additions and 99 deletions

View file

@ -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)

View file

@ -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|

View file

@ -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