diff --git a/Gemfile b/Gemfile index a99cf4ca7..42bfc3c2a 100644 --- a/Gemfile +++ b/Gemfile @@ -13,7 +13,7 @@ gem 'omniauth-openid', '~> 1.0.1' gem 'cancan', '1.6.7' # 1.6.8 fail specs with strange error gem 'ancestry', '~> 1.3.0' -gem 'paperclip', '~> 3.1.4' +gem 'paperclip', '~> 3.3.1' gem 'resque', '~> 1.21.0' gem 'resque-status', '~> 0.3.3' gem 'resque_mailer', '~> 2.1.0' diff --git a/Gemfile.lock b/Gemfile.lock index 7fbfc10d4..418bcf335 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -82,10 +82,7 @@ GEM charlock_holmes (0.6.9) chronic (0.6.7) chunky_png (1.2.7) - climate_control (0.0.3) - activesupport (>= 3.0) - cocaine (0.5.1) - climate_control (>= 0.0.3, < 1.0) + cocaine (0.4.2) coffee-rails (3.2.2) coffee-script (>= 2.2.0) railties (~> 3.2.0) @@ -206,11 +203,11 @@ GEM omniauth (~> 1.0) rack-openid (~> 1.3.1) orm_adapter (0.4.0) - paperclip (3.1.4) + paperclip (3.3.1) activemodel (>= 3.0.0) activerecord (>= 3.0.0) activesupport (>= 3.0.0) - cocaine (>= 0.0.2) + cocaine (~> 0.4.0) mime-types perform_later (1.3.0) rails (~> 3.0) @@ -415,7 +412,7 @@ DEPENDENCIES newrelic_rpm (~> 3.4.1) omniauth (~> 1.1.0) omniauth-openid (~> 1.0.1) - paperclip (~> 3.1.4) + paperclip (~> 3.3.1) perform_later (~> 1.3.0) pg (~> 0.14.0) rack-throttle diff --git a/app/assets/javascripts/extra/build_list.js b/app/assets/javascripts/extra/build_list.js index 2b03deda6..3680da92a 100644 --- a/app/assets/javascripts/extra/build_list.js +++ b/app/assets/javascripts/extra/build_list.js @@ -9,10 +9,13 @@ $(document).ready(function() { var build_platform = $('#build_for_pl_' + platform_id); var all_repositories = $('.all_platforms input'); all_repositories.removeAttr('checked'); + var use_save_to_repository = $('#build_list_use_save_to_repository'); if (build_platform.size() == 0) { all_repositories.removeAttr('disabled'); + use_save_to_repository.removeAttr('disabled'); } else { + use_save_to_repository.attr('disabled', 'disabled').attr('checked', 'checked'); all_repositories.attr('disabled', 'disabled'); var parent = build_platform.parent(); parent.find('input').removeAttr('disabled'); diff --git a/app/controllers/projects/git/base_controller.rb b/app/controllers/projects/git/base_controller.rb index fbf60d44c..f8976c2d8 100644 --- a/app/controllers/projects/git/base_controller.rb +++ b/app/controllers/projects/git/base_controller.rb @@ -10,8 +10,7 @@ class Projects::Git::BaseController < Projects::BaseController protected def set_treeish_and_path - @treeish = params[:treeish].presence || @project.default_branch - @path = params[:path] + @treeish, @path = @project.default_head(params[:treeish]), params[:path] end def set_branch_and_tree diff --git a/app/controllers/projects/git/trees_controller.rb b/app/controllers/projects/git/trees_controller.rb index f32414efd..ad940afae 100644 --- a/app/controllers/projects/git/trees_controller.rb +++ b/app/controllers/projects/git/trees_controller.rb @@ -1,7 +1,7 @@ # -*- encoding : utf-8 -*- class Projects::Git::TreesController < Projects::Git::BaseController before_filter lambda{redirect_to @project if params[:treeish] == @project.default_branch and params[:path].blank?}, :only => :show - skip_before_filter :set_branch_and_tree, :only => :archive + skip_before_filter :set_branch_and_tree, :set_treeish_and_path, :only => :archive def show @tree = @tree / @path if @path.present? @@ -10,7 +10,7 @@ class Projects::Git::TreesController < Projects::Git::BaseController end def archive - format = params[:format] + format, @treeish = params[:format], params[:treeish] if (@treeish =~ /^#{@project.owner.uname}-#{@project.name}-/) && !(@treeish =~ /[\s]+/) && (format =~ /^(zip|tar\.gz)$/) @treeish = @treeish.gsub(/^#{@project.owner.uname}-#{@project.name}-/, '') @commit = @project.repo.commits(@treeish, 1).first diff --git a/app/controllers/projects/pull_requests_controller.rb b/app/controllers/projects/pull_requests_controller.rb index 63ce7cdc0..b0157df05 100644 --- a/app/controllers/projects/pull_requests_controller.rb +++ b/app/controllers/projects/pull_requests_controller.rb @@ -152,8 +152,8 @@ class Projects::PullRequestsController < Projects::BaseController @pull.issue.body = pull_params[:issue_attributes][:body].presence end @pull.from_project = @project - @pull.to_ref = (pull_params[:to_ref].presence if pull_params) || @pull.to_project.default_branch - @pull.from_ref = params[:treeish].presence || (pull_params[:from_ref].presence if pull_params) || @pull.from_project.default_branch + @pull.to_ref = (pull_params[:to_ref].presence if pull_params) || @pull.to_project.default_head(params[:treeish]) + @pull.from_ref = params[:treeish].presence || (pull_params[:from_ref].presence if pull_params) || @pull.from_project.default_head(params[:treeish]) @pull.from_project_owner_uname = @pull.from_project.owner.uname @pull.from_project_name = @pull.from_project.name end diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 2ad6b8ee5..0f2f5d724 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -26,10 +26,10 @@ class BuildList < ActiveRecord::Base validates :update_type, :inclusion => {:in => RELEASE_UPDATE_TYPES, :message => I18n.t('flash.build_list.frozen_platform')}, :if => Proc.new { |b| b.advisory.present? } 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 + errors.add(:build_for_platform, I18n.t('flash.build_list.wrong_platform')) if save_to_platform.main? && save_to_platform_id != build_for_platform_id } validate lambda { - errors.add(:build_for_platform, I18n.t('flash.build_list.wrong_build_for_platform')) unless build_for_platform.platform_type == 'main' + errors.add(:build_for_platform, I18n.t('flash.build_list.wrong_build_for_platform')) unless build_for_platform.main? } validate lambda { errors.add(:save_to_repository, I18n.t('flash.build_list.wrong_repository')) unless save_to_repository_id.in? save_to_platform.repositories.map(&:id) @@ -43,9 +43,11 @@ class BuildList < ActiveRecord::Base errors.add(:save_to_repository, I18n.t('flash.build_list.wrong_project')) unless save_to_repository.projects.exists?(project_id) } + before_create :use_save_to_repository_for_main_platforms + 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, :project_version + :save_to_platform_id, :project_version, :use_save_to_repository LIVE_TIME = 4.week # for unpublished MAX_LIVE_TIME = 3.month # for published @@ -395,7 +397,7 @@ class BuildList < ActiveRecord::Base h["#{repo.name}_updates"] = path + 'updates' end end - if save_to_platform.personal? + 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}"] end @@ -446,4 +448,8 @@ class BuildList < ActiveRecord::Base yield p end end + + def use_save_to_repository_for_main_platforms + self.use_save_to_repository = true if save_to_platform.main? + end end diff --git a/app/models/project.rb b/app/models/project.rb index b9a795d45..f1f395ff4 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -178,6 +178,14 @@ class Project < ActiveRecord::Base AbfWorker::BuildListsPublishTaskManager.destroy_project_from_repository self, repository end + def default_head treeish = nil # maybe need change 'head'? + if repo.branches_and_tags.map(&:name).include?(treeish || default_branch) + treeish || default_branch + else + repo.branches_and_tags[0].try(:name) || default_branch + end + end + protected def truncate_name diff --git a/app/models/pull_request.rb b/app/models/pull_request.rb index a67af1587..ae549e93e 100644 --- a/app/models/pull_request.rb +++ b/app/models/pull_request.rb @@ -125,7 +125,7 @@ class PullRequest < ActiveRecord::Base def self.check_ref(record, attr, value) project = attr == :from_ref ? record.from_project : record.to_project return if project.blank? - if record.to_project.repo.commits.count > 0 + if record.to_project.repo.branches.count > 0 record.errors.add attr, I18n.t('projects.pull_requests.wrong_ref') unless project.repo.branches_and_tags.map(&:name).include?(value) else record.errors.add attr, I18n.t('projects.pull_requests.empty_repo') @@ -179,8 +179,8 @@ class PullRequest < ActiveRecord::Base system 'git', 'tag', '-d', from_ref, to_ref system 'git fetch --tags' tags, head = repo.tags.map(&:name), to_project == from_project ? 'origin' : 'head' + system 'git', 'checkout', to_ref unless tags.include? to_ref - system 'git', 'checkout', to_ref system 'git', 'reset', '--hard', "origin/#{to_ref}" end unless tags.include? from_ref diff --git a/app/views/api/v1/build_lists/show.json.jbuilder b/app/views/api/v1/build_lists/show.json.jbuilder index 004109489..720d9a48e 100644 --- a/app/views/api/v1/build_lists/show.json.jbuilder +++ b/app/views/api/v1/build_lists/show.json.jbuilder @@ -1,7 +1,7 @@ json.build_list do |json| json.(@build_list, :id, :name, :container_status, :status, :duration) json.(@build_list, :is_circle, :update_type, :priority, :new_core) - json.(@build_list, :advisory, :mass_build) + json.(@build_list, :advisory, :mass_build, :use_save_to_repository) json.(@build_list, :auto_publish, :package_version, :commit_hash, :last_published_commit_hash) json.build_log_url log_build_list_path(@build_list) diff --git a/app/views/projects/base/_submenu.html.haml b/app/views/projects/base/_submenu.html.haml index 67b6fb37d..e74348da6 100644 --- a/app/views/projects/base/_submenu.html.haml +++ b/app/views/projects/base/_submenu.html.haml @@ -1,5 +1,5 @@ - content_for :submenu do - - act = action_name.to_sym; contr = controller_name.to_sym; treeish = params[:treeish].presence || @project.default_branch + - act = action_name.to_sym; contr = controller_name.to_sym; treeish = @project.default_head(params[:treeish]) .left .table-sort-left=image_tag visibility_icon(@project.visibility) .table-sort-right=@project.name diff --git a/app/views/projects/build_lists/new.html.haml b/app/views/projects/build_lists/new.html.haml index 04322b59d..b401a5a2c 100644 --- a/app/views/projects/build_lists/new.html.haml +++ b/app/views/projects/build_lists/new.html.haml @@ -26,6 +26,9 @@ .both = f.check_box :auto_publish = f.label :auto_publish + .both + = f.check_box :use_save_to_repository + = f.label :use_save_to_repository %br = f.submit t("layout.projects.build_button") diff --git a/app/views/projects/build_lists/show.html.haml b/app/views/projects/build_lists/show.html.haml index b7f3bda44..0cc9f150c 100644 --- a/app/views/projects/build_lists/show.html.haml +++ b/app/views/projects/build_lists/show.html.haml @@ -37,6 +37,9 @@ .rightlist = link_to "#{@build_list.save_to_platform.name}/#{@build_list.save_to_repository.name}", [@build_list.save_to_platform, @build_list.save_to_repository] .both + .leftlist= t("activerecord.attributes.build_list.use_save_to_repository") + .rightlist= t("layout.#{@build_list.use_save_to_repository?}_") + .both .leftlist= t("activerecord.attributes.build_list.include_repos") .rightlist= (@build_list.include_repos||[]).map{|r| Repository.find(r).name}.join(', ') .both diff --git a/config/locales/models/build_list.en.yml b/config/locales/models/build_list.en.yml index 24bb0f914..0e0dfb81f 100644 --- a/config/locales/models/build_list.en.yml +++ b/config/locales/models/build_list.en.yml @@ -20,6 +20,7 @@ en: include_repos: Included repositories created_at: Created on save_to_repository: Save to repository + use_save_to_repository: Use 'save to repository' for assembly build_for_platform: Build for platform update_type: Update type auto_publish: Automated publising diff --git a/config/locales/models/build_list.ru.yml b/config/locales/models/build_list.ru.yml index 2c83bae9d..e4fdaf8f3 100644 --- a/config/locales/models/build_list.ru.yml +++ b/config/locales/models/build_list.ru.yml @@ -20,6 +20,7 @@ ru: include_repos: Подключаемые репозитории created_at: Создан save_to_repository: Сохранить в репозиторий + use_save_to_repository: Использовать 'cохранить в репозиторий' для сборки build_for_platform: Собрано для платформы update_type: Критичность обновления auto_publish: Автоматическая публикация diff --git a/db/migrate/20130201094007_add_use_personal_repository_to_build_list.rb b/db/migrate/20130201094007_add_use_personal_repository_to_build_list.rb new file mode 100644 index 000000000..ae24ae61e --- /dev/null +++ b/db/migrate/20130201094007_add_use_personal_repository_to_build_list.rb @@ -0,0 +1,5 @@ +class AddUsePersonalRepositoryToBuildList < ActiveRecord::Migration + def change + add_column :build_lists, :use_save_to_repository, :boolean, :default => true + end +end diff --git a/db/schema.rb b/db/schema.rb index 905c21b04..d8d8791d0 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 => 20130129145833) do +ActiveRecord::Schema.define(:version => 20130201094007) do create_table "activity_feeds", :force => true do |t| t.integer "user_id", :null => false @@ -133,6 +133,7 @@ ActiveRecord::Schema.define(:version => 20130129145833) do t.boolean "new_core", :default => true t.string "last_published_commit_hash" t.integer "container_status" + t.boolean "use_save_to_repository", :default => true end add_index "build_lists", ["advisory_id"], :name => "index_build_lists_on_advisory_id"