#265: rename folders with pull_requests
This commit is contained in:
parent
4c254747ae
commit
81f82cbb7d
|
@ -288,7 +288,9 @@ class Project < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def update_path_to_project(old_name)
|
||||
new_name, new_path, self.name, old_path = name, path, old_name, path
|
||||
new_name, new_path = name, path
|
||||
self.name = old_name
|
||||
old_path = path
|
||||
self.name = new_name
|
||||
FileUtils.mv old_path, new_path, :force => true
|
||||
|
||||
|
@ -298,9 +300,8 @@ class Project < ActiveRecord::Base
|
|||
|
||||
PullRequest.where(:from_project_id => id).update_all(:from_project_name => new_name)
|
||||
|
||||
PullRequest.where('from_project_id = ? OR to_project_id = ?', id, id).find_in_batches(:batch_size => 100) do |pulls|
|
||||
pulls.each(&:update_relations)
|
||||
end
|
||||
PullRequest.where(:from_project_id => id).each{ |p| p.update_relations(old_name) }
|
||||
pull_requests.where('from_project_id != to_project_id').each(&:update_relations)
|
||||
end
|
||||
later :update_path_to_project, :queue => :clone_build
|
||||
|
||||
|
|
|
@ -49,7 +49,8 @@ class PullRequest < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def update_relations
|
||||
def update_relations(old_from_project_name)
|
||||
FileUtils.mv path(old_from_project_name), path, :force => true if old_from_project_name
|
||||
return unless Dir.exists?(path)
|
||||
Dir.chdir(path) do
|
||||
system 'git', 'remote', 'remove', 'origin'
|
||||
|
@ -116,8 +117,8 @@ class PullRequest < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def path
|
||||
last_part = [id, from_project_owner_uname, from_project_name].compact.join('-')
|
||||
def path(suffix = from_project_name)
|
||||
last_part = [id, from_project_owner_uname, suffix].compact.join('-')
|
||||
File.join(APP_CONFIG['git_path'], "#{new_record? ? 'temp_' : ''}pull_requests", to_project.owner.uname, to_project.name, last_part)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue