[refs #90] fixed migration & task for pull path
This commit is contained in:
parent
06421dbdec
commit
8b2126d2a7
|
@ -4,7 +4,11 @@ class AddHelpersColumnsToPullRequest < ActiveRecord::Migration
|
||||||
add_column :pull_requests, :from_project_name, :string
|
add_column :pull_requests, :from_project_name, :string
|
||||||
# includes generate error "undefined method `repo' for nil:NilClass"
|
# includes generate error "undefined method `repo' for nil:NilClass"
|
||||||
# update not orphan pulls. For other need execute a task project:fix_orphan_pulls
|
# update not orphan pulls. For other need execute a task project:fix_orphan_pulls
|
||||||
PullRequest.joins(:from_project).each {|pull| pull.from_project_name = pull.from_project.name}
|
PullRequest.joins(:from_project).each do |pull|
|
||||||
|
pull.from_project_name = pull.from_project.name
|
||||||
|
pull.from_project_owner_uname = pull.from_project.owner.uname
|
||||||
|
pull.save
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def down
|
def down
|
||||||
|
|
|
@ -5,7 +5,12 @@ namespace :project do
|
||||||
say "Pull requests total count is #{PullRequest.count}"
|
say "Pull requests total count is #{PullRequest.count}"
|
||||||
PullRequest.all.each_with_index do |pull, ind|
|
PullRequest.all.each_with_index do |pull, ind|
|
||||||
say "Check pull with id:#{pull.id} (#{ind+1}/#{PullRequest.count})"
|
say "Check pull with id:#{pull.id} (#{ind+1}/#{PullRequest.count})"
|
||||||
unless pull.from_project.present?
|
if pull.from_project.present?
|
||||||
|
print ' updating...'
|
||||||
|
pull.from_project_name = pull.from_project.name
|
||||||
|
pull.from_project_owner_uname = pull.from_project.owner.uname
|
||||||
|
say pull.save(:validate => false) ? 'success' : 'fail!'
|
||||||
|
else
|
||||||
print ' its orphan! updating...'
|
print ' its orphan! updating...'
|
||||||
parent_path = File.join(APP_CONFIG['git_path'], 'pull_requests', pull.to_project.owner.uname, pull.to_project.name)
|
parent_path = File.join(APP_CONFIG['git_path'], 'pull_requests', pull.to_project.owner.uname, pull.to_project.name)
|
||||||
Dir.chdir(parent_path) do
|
Dir.chdir(parent_path) do
|
||||||
|
|
Loading…
Reference in New Issue