From a2a29e2baade24a64588c5dde1c8c639c68a5814 Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Thu, 23 Feb 2012 17:17:02 +0200 Subject: [PATCH] Rescue and ignore timeout error during long XML RPC. Apply add_branch script. Refs #207 --- lib/build_server.rb | 16 +++++++++------- lib/tasks/add_branch.rake | 22 ++++++++++++++++++++++ 2 files changed, 31 insertions(+), 7 deletions(-) create mode 100644 lib/tasks/add_branch.rake diff --git a/lib/build_server.rb b/lib/build_server.rb index 2bf6cfc9a..9aa2be76e 100644 --- a/lib/build_server.rb +++ b/lib/build_server.rb @@ -28,33 +28,35 @@ class BuildServer self.client.call('add_platform', name, platforms_root_folder, repos, distrib_type) end - def self.delete_platform name self.client.call('delete_platform', name) + rescue Timeout::Error => e # TODO remove this when core will be ready + 0 end - def self.clone_platform new_name, old_name, new_root_folder self.client.call('clone_platform', new_name, old_name, new_root_folder) + rescue Timeout::Error => e # TODO remove this when core will be ready + 0 end - def self.create_repo name, platform_name self.client.call('create_repository', name, platform_name) end - def self.delete_repo name, platform_name self.client.call('delete_repository', name, platform_name) + rescue Timeout::Error => e # TODO remove this when core will be ready + 0 end def self.clone_repo new_name, old_name, new_platform_name - tmp = self.client.timeout # TODO remove this when core will be ready - self.client.timeout = 30.minutes self.client.call('clone_repo', new_name, old_name, new_platform_name) - self.client.timeout = tmp + rescue Timeout::Error => e # TODO remove this when core will be ready + 0 end + def self.publish_container container_id self.client.call('publish_container', container_id) end diff --git a/lib/tasks/add_branch.rake b/lib/tasks/add_branch.rake new file mode 100644 index 000000000..1a7b96bd5 --- /dev/null +++ b/lib/tasks/add_branch.rake @@ -0,0 +1,22 @@ +require 'highline/import' + +desc "Add branch for platform projects" +task :add_branch => :environment do + src_branch = ENV['SRC_BRANCH'] || 'import_mandriva2011' + dst_branch = ENV['DST_BRANCH'] || 'rosa2012lts' + + say "START add branch #{dst_branch} from #{src_branch}" + Platform.find_by_name(dst_branch).repositories.each do |r| + say "=== Process #{r.name} repo" + r.projects.find_each do |p| + say "===== Process #{p.name} project" + tmp_path = Rails.root.join('tmp', p.name) + system("git clone #{p.path} #{tmp_path}") + system("cd #{tmp_path} && git checkout remotes/origin/#{src_branch}") or system("cd #{tmp_path} && git checkout master") + system("cd #{tmp_path} && git checkout -b #{dst_branch}") + system("cd #{tmp_path} && git push origin HEAD") + FileUtils.rm_rf tmp_path + end + end + say 'DONE' +end