From 8319fe8e9b8c5d009fff38f3cccca971f6844a7c Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Thu, 16 May 2013 18:48:44 +0400 Subject: [PATCH 1/3] #133: attach only personal repositories to the build --- app/controllers/projects/build_lists_controller.rb | 3 ++- app/models/build_list.rb | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/projects/build_lists_controller.rb b/app/controllers/projects/build_lists_controller.rb index 35199f2e0..fbc90a927 100644 --- a/app/controllers/projects/build_lists_controller.rb +++ b/app/controllers/projects/build_lists_controller.rb @@ -120,7 +120,8 @@ class Projects::BuildListsController < Projects::BaseController if save_to_platform.main? bl = bl.where(:save_to_platform_id => save_to_platform.id) else - platforms = Platform.includes(:repositories).search(params[:term]). + # Only personal repositories can be attached to the build + platforms = Platform.includes(:repositories).personal.search(params[:term]). accessible_by(current_ability, :read).search_order.limit(5) platforms.each{ |p| p.repositories.each{ |r| results << {:id => r.id, :label => "#{p.name}/#{r.name}", :value => "#{p.name}/#{r.name}"} } } end diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 132050a34..e72834523 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -488,7 +488,8 @@ class BuildList < ActiveRecord::Base if save_to_platform && save_to_platform.main? self.extra_repositories = nil else - self.extra_repositories = Repository.where(:id => extra_repositories). + self.extra_repositories = Repository.joins(:platform). + where(:id => extra_repositories, :platforms => {:platform_type => 'personal'}). accessible_by(current_ability, :read).pluck('repositories.id') end end From da288fb843452500e4227af81732ecc108fcf475 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Thu, 16 May 2013 19:25:03 +0400 Subject: [PATCH 2/3] #133: updated paths to extra repos, refactoring --- app/models/build_list.rb | 14 +++++++++++--- app/models/platform.rb | 4 ++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/app/models/build_list.rb b/app/models/build_list.rb index e72834523..01fea4b0a 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -409,13 +409,17 @@ class BuildList < ActiveRecord::Base repos = include_repos include_repos_hash = {}.tap do |h| Repository.where(:id => (repos | (extra_repositories || [])) ).each do |repo| - path = repo.platform.public_downloads_url(arch.name, repo.name) - # path.gsub!(/^http:\/\/(0\.0\.0\.0|localhost)\:[\d]+/, 'https://abf.rosalinux.ru') unless Rails.env.production? # Path looks like: # http://abf-downloads.rosalinux.ru/rosa-server2012/repository/x86_64/base/ + # http://abf-downloads.rosalinux.ru/uname_personal/repository/rosa-server2012/x86_64/base/ # so, we should append: # - release # - updates + path = repo.platform.public_downloads_url( + repo.platform.main? ? nil : build_for_platform.name, + arch.name, + repo.name + ) h["#{repo.platform.name}_#{repo.name}_release"] = path + 'release' h["#{repo.platform.name}_#{repo.name}_updates"] = path + 'updates' if repo.platform.main? end @@ -428,7 +432,11 @@ class BuildList < ActiveRecord::Base end if save_to_platform.personal? && use_save_to_repository include_repos_hash["#{save_to_platform.name}_release"] = save_to_platform. - urpmi_list(nil, nil, false, save_to_repository.name)["#{build_for_platform.name}"]["#{arch.name}"] + public_downloads_url( + build_for_platform.name, + arch.name, + save_to_repository.name + ) + 'release' end git_project_address = project.git_project_address(user) diff --git a/app/models/platform.rb b/app/models/platform.rb index f642fd1e6..db4dfa70a 100644 --- a/app/models/platform.rb +++ b/app/models/platform.rb @@ -91,11 +91,11 @@ class Platform < ActiveRecord::Base Rails.root.join("public", "downloads", name) end - def public_downloads_url(arch = nil, repo = nil, suffix = nil) + def public_downloads_url(subplatform_name = nil, arch = nil, repo = nil) "#{APP_CONFIG['downloads_url']}/#{name}/repository/".tap do |url| + url << "#{subplatform_name}/" if subplatform_name.present? url << "#{arch}/" if arch.present? url << "#{repo}/" if repo.present? - url << "#{suffix}/" if suffix.present? end end From c6178a81ab19d1a1cc99a87b5e7c202dd04a9159 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Thu, 16 May 2013 21:44:56 +0400 Subject: [PATCH 3/3] #133: added comments --- app/models/build_list.rb | 6 ------ app/models/platform.rb | 3 +++ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 01fea4b0a..6488a8638 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -409,12 +409,6 @@ class BuildList < ActiveRecord::Base repos = include_repos include_repos_hash = {}.tap do |h| Repository.where(:id => (repos | (extra_repositories || [])) ).each do |repo| - # Path looks like: - # http://abf-downloads.rosalinux.ru/rosa-server2012/repository/x86_64/base/ - # http://abf-downloads.rosalinux.ru/uname_personal/repository/rosa-server2012/x86_64/base/ - # so, we should append: - # - release - # - updates path = repo.platform.public_downloads_url( repo.platform.main? ? nil : build_for_platform.name, arch.name, diff --git a/app/models/platform.rb b/app/models/platform.rb index db4dfa70a..67ad038ff 100644 --- a/app/models/platform.rb +++ b/app/models/platform.rb @@ -91,6 +91,9 @@ class Platform < ActiveRecord::Base Rails.root.join("public", "downloads", name) end + # Returns URL to repository, for example: + # - http://abf-downloads.rosalinux.ru/rosa-server2012/repository/x86_64/base/ + # - http://abf-downloads.rosalinux.ru/uname_personal/repository/rosa-server2012/x86_64/base/ def public_downloads_url(subplatform_name = nil, arch = nil, repo = nil) "#{APP_CONFIG['downloads_url']}/#{name}/repository/".tap do |url| url << "#{subplatform_name}/" if subplatform_name.present?