diff --git a/app/controllers/platforms/mass_builds_controller.rb b/app/controllers/platforms/mass_builds_controller.rb index c12d82768..e9b866103 100644 --- a/app/controllers/platforms/mass_builds_controller.rb +++ b/app/controllers/platforms/mass_builds_controller.rb @@ -12,7 +12,8 @@ class Platforms::MassBuildsController < Platforms::BaseController def create mass_build = @platform.mass_builds.new(:arches => params[:arches], :auto_publish => params[:auto_publish] || false, - :projects_list => params[:projects_list]) + :projects_list => params[:projects_list], + :new_core => params[:new_core]) mass_build.user = current_user authorize! :create, mass_build diff --git a/app/controllers/projects/pull_requests_controller.rb b/app/controllers/projects/pull_requests_controller.rb index 2b0b9f309..63ce7cdc0 100644 --- a/app/controllers/projects/pull_requests_controller.rb +++ b/app/controllers/projects/pull_requests_controller.rb @@ -111,7 +111,8 @@ class Projects::PullRequestsController < Projects::BaseController def autocomplete_to_project items = Project.accessible_by(current_ability, :membered) | @project.ancestors - items.select! {|e| Regexp.new(params[:term].downcase).match(e.name_with_owner.downcase) && e.repo.branches.count > 0} + term = Regexp.new(Regexp.escape params[:term].downcase) + items.select! {|e| term.match(e.name_with_owner.downcase) && e.repo.branches.count > 0} render :json => json_for_autocomplete_base(items) end diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 9ca1e8152..39d1fed42 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -39,6 +39,9 @@ class BuildList < ActiveRecord::Base } } + attr_accessible :include_repos, :auto_publish, :build_for_platform_id, :commit_hash, + :arch_id, :project_id, :save_to_repository_id, :update_type, + :save_to_platform_id, :new_core, :project_version LIVE_TIME = 4.week # for unpublished MAX_LIVE_TIME = 3.month # for published @@ -265,7 +268,7 @@ class BuildList < ActiveRecord::Base end def publish_container - type = save_to_platform.distrib_type + type = build_for_platform.distrib_type archive = results.select{ |r| r['file_name'] =~ /.*\.tar\.gz$/}[0] platform_path = "#{save_to_platform.path}/repository" diff --git a/app/models/mass_build.rb b/app/models/mass_build.rb index 1342eaf59..6b5a46c31 100644 --- a/app/models/mass_build.rb +++ b/app/models/mass_build.rb @@ -7,7 +7,7 @@ class MassBuild < ActiveRecord::Base scope :outdated, where('created_at < ?', Time.now + 1.day - BuildList::MAX_LIVE_TIME) attr_accessor :arches - attr_accessible :arches, :auto_publish, :projects_list + attr_accessible :arches, :auto_publish, :projects_list, :new_core validates :platform_id, :arch_names, :name, :user_id, :projects_list, :presence => true validates_inclusion_of :auto_publish, :in => [true, false] @@ -38,7 +38,7 @@ class MassBuild < ActiveRecord::Base return if self.reload.stop_build arches_list.each do |arch| rep = (project.repositories & platform.repositories).first - project.build_for(platform, rep.id, user, arch, auto_publish, self.id) + project.build_for(platform, rep.id, user, arch, auto_publish, self.id, 0, new_core) end rescue RuntimeError, Exception end diff --git a/app/models/platform.rb b/app/models/platform.rb index 1dcee17a9..721b3cb3d 100644 --- a/app/models/platform.rb +++ b/app/models/platform.rb @@ -63,7 +63,9 @@ class Platform < ActiveRecord::Base pair = blank_pair if pair.blank? urpmi_commands = ActiveSupport::OrderedHash.new - Platform.main.opened.where(:distrib_type => APP_CONFIG['distr_types'].first).each do |pl| + # TODO: rename method or create separate methods for mdv and rhel + # Platform.main.opened.where(:distrib_type => APP_CONFIG['distr_types'].first).each do |pl| + Platform.main.opened.each do |pl| urpmi_commands[pl.name] = {} local_pair = pl.id != self.id ? blank_pair : pair head = hidden? ? "http://#{local_pair[:login]}@#{local_pair[:pass]}:#{host}/private/" : "http://#{host}/downloads/" @@ -210,4 +212,4 @@ class Platform < ActiveRecord::Base repositories.update_all(:publish_without_qa => false) end end -end \ No newline at end of file +end diff --git a/app/models/project.rb b/app/models/project.rb index d7f462c7f..cedd03f26 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -130,7 +130,7 @@ class Project < ActiveRecord::Base #path #share by NFS end - def build_for(platform, repository_id, user, arch = Arch.find_by_name('i586'), auto_publish = false, mass_build_id = nil, priority = 0) + def build_for(platform, repository_id, user, arch = Arch.find_by_name('i586'), auto_publish = false, mass_build_id = nil, priority = 0, new_core = false) # Select main and project platform repository(contrib, non-free and etc) # If main does not exist, will connect only project platform repository # If project platform repository is main, only main will be connect @@ -149,6 +149,7 @@ class Project < ActiveRecord::Base bl.priority = priority bl.mass_build_id = mass_build_id bl.save_to_repository_id = repository_id + bl.new_core = new_core end end diff --git a/app/views/platforms/mass_builds/index.html.haml b/app/views/platforms/mass_builds/index.html.haml index 91aa5269f..338f2db1f 100644 --- a/app/views/platforms/mass_builds/index.html.haml +++ b/app/views/platforms/mass_builds/index.html.haml @@ -16,8 +16,10 @@ %h3= t("activerecord.attributes.build_list.preferences") .both.bottom_20 = check_box_tag :auto_publish, true, @auto_publish_selected, :id => 'auto_publish' - = label_tag :auto_publish - + = label_tag :auto_publish, t('activerecord.attributes.build_list.auto_publish') + %br + = check_box_tag :new_core, true, false + = label_tag :new_core, t('activerecord.attributes.build_list.new_core') %br %br diff --git a/db/migrate/20121225103309_add_new_core_to_mass_build.rb b/db/migrate/20121225103309_add_new_core_to_mass_build.rb new file mode 100644 index 000000000..0d04e5df0 --- /dev/null +++ b/db/migrate/20121225103309_add_new_core_to_mass_build.rb @@ -0,0 +1,5 @@ +class AddNewCoreToMassBuild < ActiveRecord::Migration + def change + add_column :mass_builds, :new_core, :boolean, :default => false + end +end diff --git a/db/schema.rb b/db/schema.rb index dc16a6137..b41437f7f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20121224125838) do +ActiveRecord::Schema.define(:version => 20121225103309) do create_table "activity_feeds", :force => true do |t| t.integer "user_id", :null => false @@ -265,6 +265,7 @@ ActiveRecord::Schema.define(:version => 20121224125838) do t.text "projects_list" t.integer "missed_projects_count", :default => 0, :null => false t.text "missed_projects_list" + t.boolean "new_core", :default => false end create_table "platforms", :force => true do |t| diff --git a/lib/tasks/build.rake b/lib/tasks/build.rake index b431fd2af..c0f414df6 100644 --- a/lib/tasks/build.rake +++ b/lib/tasks/build.rake @@ -13,7 +13,7 @@ namespace :build do open(source).readlines.each do |name| name.chomp!; name.strip! #; name.downcase! if p = Project.joins(:repositories).where('repositories.id IN (?)', platform.repositories).find_by_name(name) - p.build_for(platform, owner, arch) + # Old code p.build_for(platform, owner, arch) say "== Build #{p.name} ==" else say "== Not found #{name} ==" diff --git a/spec/controllers/api/v1/build_lists_controller_spec.rb b/spec/controllers/api/v1/build_lists_controller_spec.rb index 7df1e1eb3..fac3eb24e 100644 --- a/spec/controllers/api/v1/build_lists_controller_spec.rb +++ b/spec/controllers/api/v1/build_lists_controller_spec.rb @@ -98,7 +98,8 @@ describe Api::V1::BuildListsController do @build_list.save_to_platform.relations.create(:role => 'admin', :actor => @owner_user) # Why it's really need it?? # Create and show params: - @create_params = {:build_list => @build_list.attributes.symbolize_keys.except(:bs_id)} + @create_params = {:build_list => @build_list.attributes.symbolize_keys.except(:bs_id) + .merge(:qwerty=>'!')} # wrong parameter @create_params = @create_params.merge(:arches => [@params[:arch_id]], :build_for_platforms => [@params[:build_for_platform_id]], :format => :json) any_instance_of(Project, :versions => ['v1.0', 'v2.0']) diff --git a/spec/models/build_list_spec.rb b/spec/models/build_list_spec.rb index 8223caacb..fdce8c035 100644 --- a/spec/models/build_list_spec.rb +++ b/spec/models/build_list_spec.rb @@ -16,8 +16,8 @@ describe BuildList do before(:all) { ActionMailer::Base.deliveries = [] } before do - build_list.update_attributes(:commit_hash => build_list.project.repo.commits('master').last.id, - :status => BuildServer::BUILD_STARTED,) + build_list.update_attributes({:commit_hash => build_list.project.repo.commits('master').last.id, + :status => BuildServer::BUILD_STARTED}, :without_protection => true) end after { ActionMailer::Base.deliveries = [] } @@ -39,25 +39,25 @@ describe BuildList do end it "gets notification by email when status - Failed publish" do - build_list.update_attributes(:status => BuildList::BUILD_PUBLISH) + build_list.update_attributes({:status => BuildList::BUILD_PUBLISH}, :without_protection => true) build_list.fail_publish should have(1).item end it "gets notification by email when auto_publish and status - Failed publish" do - build_list.update_attributes(:auto_publish => true, :status => BuildList::BUILD_PUBLISH) + build_list.update_attributes({:auto_publish => true, :status => BuildList::BUILD_PUBLISH}, :without_protection => true) build_list.fail_publish should have(1).item end it "gets notification by email when status - Build published" do - build_list.update_attributes(:status => BuildList::BUILD_PUBLISH) + build_list.update_attributes({:status => BuildList::BUILD_PUBLISH}, :without_protection => true) build_list.published should have(1).item end it "gets notification by email when auto_publish and status - Build published" do - build_list.update_attributes(:auto_publish => true, :status => BuildList::BUILD_PUBLISH) + build_list.update_attributes({:auto_publish => true, :status => BuildList::BUILD_PUBLISH}, :without_protection => true) build_list.published should have(1).item end @@ -69,7 +69,7 @@ describe BuildList do end it "doesn't get notification by email when mass build" do - build_list.update_attributes(:mass_build_id => 1, :status => BuildList::BUILD_PUBLISH) + build_list.update_attributes({:mass_build_id => 1, :status => BuildList::BUILD_PUBLISH}, :without_protection => true) build_list.published should have(:no).items end @@ -133,8 +133,8 @@ describe BuildList do :auto_publish => true, :project => FactoryGirl.create(:project_with_commit, :owner => user)) FactoryGirl.create(:build_list_package, :build_list => bl, :project => bl.project) - bl.update_attributes(:commit_hash => bl.project.repo.commits('master').last.id, - :status => BuildList::BUILD_PUBLISH) + bl.update_attributes({:commit_hash => bl.project.repo.commits('master').last.id, + :status => BuildList::BUILD_PUBLISH}, :without_protection => true) bl.published should have(1).item end