From 5db6be8d87c4a357c37d22a2271396cc632c1235 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Tue, 10 Sep 2013 17:58:58 +0400 Subject: [PATCH] #298: added checking of new packages on publishing of mass_build --- app/models/build_list.rb | 8 +++++--- app/models/mass_build.rb | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/models/build_list.rb b/app/models/build_list.rb index aa16cbf3a..24916e72c 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -280,9 +280,7 @@ class BuildList < ActiveRecord::Base build_started? || build_pending? end - def can_auto_publish? - return false if !(auto_publish? && can_publish?) - + def has_new_packages? if last_bl = last_published.joins(:source_packages).where(:build_list_packages => {:actual => true}).last source_packages.each do |nsp| sp = last_bl.source_packages.find{ |sp| nsp.name == sp.name } @@ -298,6 +296,10 @@ class BuildList < ActiveRecord::Base return false # no new packages end + def can_auto_publish? + auto_publish? && can_publish? && has_new_packages? + end + def can_publish? [SUCCESS, FAILED_PUBLISH, BUILD_PUBLISHED, TESTS_FAILED].include?(status) && extra_build_lists_published? && save_to_repository.projects.exists?(:id => project_id) end diff --git a/app/models/mass_build.rb b/app/models/mass_build.rb index b8b089d94..d00a43822 100644 --- a/app/models/mass_build.rb +++ b/app/models/mass_build.rb @@ -99,7 +99,7 @@ class MassBuild < ActiveRecord::Base builds = build_lists.where(:status => statuses) builds.update_all(:publisher_id => user.id) builds.order(:id).find_in_batches(:batch_size => 50) do |bls| - bls.each{ |bl| bl.can_publish? && bl.now_publish } + bls.each{ |bl| bl.can_publish? && bl.has_new_packages? && bl.now_publish } end end