From 57ef02044166ff584e8bf8ffec440da6a59cc590 Mon Sep 17 00:00:00 2001 From: Vladimir Sharshov Date: Tue, 22 May 2012 01:10:00 +0400 Subject: [PATCH 1/3] [refs #442] Fix problem for build list with save_to plaftorm is freeze; fix ignoring auto_publish option. --- app/models/build_list.rb | 2 +- app/models/mass_build.rb | 3 ++- app/models/project.rb | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 8060ce219..5d8a93e9d 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -18,7 +18,7 @@ class BuildList < ActiveRecord::Base validates :update_type, :inclusion => UPDATE_TYPES, :unless => Proc.new { |b| b.save_to_platform.released } validates :update_type, :inclusion => RELEASE_UPDATE_TYPES, - :if => Proc.new { |b| b.save_to_platform.released } + :if => Proc.new { |b| b.save_to_platform.released && b.mass_build_id.nil?} validate lambda { errors.add(:build_for_platform, I18n.t('flash.build_list.wrong_platform')) if save_to_platform.platform_type == 'main' && save_to_platform_id != build_for_platform_id } diff --git a/app/models/mass_build.rb b/app/models/mass_build.rb index b626bed53..8739df6a4 100644 --- a/app/models/mass_build.rb +++ b/app/models/mass_build.rb @@ -5,7 +5,8 @@ class MassBuild < ActiveRecord::Base def build_all(opts={}) set_name opts[:repositories] - platform.build_all opts.merge({:mass_build_id => self.id}) + opts.merge!({:mass_build_id => self.id}) + platform.build_all opts end private diff --git a/app/models/project.rb b/app/models/project.rb index f40717e41..c6501721b 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -76,7 +76,7 @@ class Project < ActiveRecord::Base # If project platform repository is main, only main will be connect build_reps = [platform.repositories.find_by_name('main')] build_reps += platform.repositories.select {|rep| self.repository_ids.include? rep.id} - build_ids = build_reps.compact.map(&:id).uniq + build_reps_ids = build_reps.compact.map(&:id).uniq arch = Arch.find_by_name(arch) if arch.acts_like?(:string) build_lists.create do |bl| bl.save_to_platform = platform @@ -86,8 +86,8 @@ class Project < ActiveRecord::Base bl.project_version = "latest_#{platform.name}" bl.build_requires = false # already set as db default bl.user = user - bl.auto_publish = true # already set as db default - bl.include_repos = build_ids + bl.auto_publish = auto_publish + bl.include_repos = build_reps_ids bl.priority = priority bl.mass_build_id = mass_build_id end From ec711eff4816dba9270874a47b1aabaf843aa9f8 Mon Sep 17 00:00:00 2001 From: Vladimir Sharshov Date: Tue, 22 May 2012 23:41:34 +0400 Subject: [PATCH 2/3] [refs #442] Fix: always set true for auto_publish params --- app/models/platform.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/platform.rb b/app/models/platform.rb index 2face5a28..bde879c34 100644 --- a/app/models/platform.rb +++ b/app/models/platform.rb @@ -161,7 +161,7 @@ class Platform < ActiveRecord::Base # Set options to build all need repositories = opts[:repositories] ? self.repositories.where(:id => opts[:repositories]) : self.repositories arches = opts[:arches] ? Arch.where(:id => opts[:arches]) : Arch.all - auto_publish = opts[:auto_publish] || true + auto_publish = opts[:auto_publish] || false user = opts[:user] mass_build_id = opts[:mass_build_id] From 70a89dccd0d7b240b6849d82f720a6c8ef8d6b6a Mon Sep 17 00:00:00 2001 From: Vladimir Sharshov Date: Wed, 23 May 2012 14:52:23 +0400 Subject: [PATCH 3/3] [refs #430] Delete containers after deleting build list --- app/models/build_list.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 5d8a93e9d..c20b7b9f4 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -98,6 +98,7 @@ class BuildList < ActiveRecord::Base before_create :set_default_status after_create :place_build + after_destroy :delete_container def self.human_status(status) I18n.t("layout.build_lists.statuses.#{HUMAN_STATUSES[status]}") @@ -192,6 +193,15 @@ class BuildList < ActiveRecord::Base save end + + def delete_container + if can_cancel? + BuildServer.delete_build_list bs_id + else + BuildServer.delete_container bs_id if bs_id # prevent error if bs_id does not set + end + end + def build_package(pkg_hash, package_type, prj) packages.create(pkg_hash) do |p| p.project = prj