#394: add ability to set forbid_to_publish_builds_not_from

This commit is contained in:
Vokhmin Alexey V 2014-05-31 00:08:45 +04:00
parent c664f77737
commit 94f1edc3e3
7 changed files with 28 additions and 9 deletions

View File

@ -606,11 +606,12 @@ class BuildList < ActiveRecord::Base
def valid_branch_for_publish?
return true if save_to_platform.personal? ||
( project_version == save_to_platform.name ) ||
( save_to_platform.main? && !save_to_repository.forbid_to_publish_builds_not_from? )
save_to_repository.forbid_to_publish_builds_not_from.blank? ||
( project_version == save_to_repository.forbid_to_publish_builds_not_from )
project.repo.git.native(:branch, {}, '--contains', commit_hash).
gsub(/\*/, '').split(/\n/).map(&:strip).include?(save_to_platform.name)
gsub(/\*/, '').split(/\n/).map(&:strip).
include?(save_to_repository.forbid_to_publish_builds_not_from)
end

View File

@ -23,6 +23,7 @@ class Repository < ActiveRecord::Base
validates :description, presence: true
validates :name, uniqueness: { scope: :platform_id, case_sensitive: false }, presence: true,
format: { with: /\A[a-z0-9_\-]+\z/ }
validates :forbid_to_publish_builds_not_from, length: { maximum: 255 }
scope :recent, -> { order(:name) }
scope :main, -> { where(name: %w(main base)) }

View File

@ -13,8 +13,8 @@
- if @platform.main?
.both
.leftlist= f.label :forbid_to_publish_builds_not_from, t('activerecord.attributes.repository.forbid_to_publish_builds_not_from', name: @platform.name)
.rightlist= f.check_box :forbid_to_publish_builds_not_from
.leftlist= f.label :forbid_to_publish_builds_not_from
.rightlist= f.text_field :forbid_to_publish_builds_not_from
.both

View File

@ -71,4 +71,4 @@ en:
updated_at: Updated
owner: Owner
synchronizing_publications: Publish only on success all build_lists for each arch (checking by commit hash)
forbid_to_publish_builds_not_from: "Forbid to publish builds not from '%{name}' branch"
forbid_to_publish_builds_not_from: "Forbid to publish builds not from branch"

View File

@ -71,4 +71,5 @@ ru:
updated_at: Обновлен
owner: Владелец
synchronizing_publications: Публиковать сборочные листы только при успешной сборке под каждую архитектуру (проверка по хэшу коммита)
forbid_to_publish_builds_not_from: "Запрет на публикацию сборок не из '%{name}' ветки"
forbid_to_publish_builds_not_from: "Запрет на публикацию сборок не из ветки"

View File

@ -0,0 +1,16 @@
class ChangeTypeOfForbidToPublishBuildsNotFromInRepositories < ActiveRecord::Migration
def up
remove_column :repositories, :forbid_to_publish_builds_not_from
add_column :repositories, :forbid_to_publish_builds_not_from, :string
execute <<-SQL
UPDATE repositories SET forbid_to_publish_builds_not_from = platforms.name
FROM platforms
WHERE repositories.platform_id = platforms.id
SQL
end
def down
remove_column :repositories, :forbid_to_publish_builds_not_from
add_column :repositories, :forbid_to_publish_builds_not_from, :boolean, null: false, default: true
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20140528170054) do
ActiveRecord::Schema.define(version: 20140530193652) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -529,7 +529,7 @@ ActiveRecord::Schema.define(version: 20140528170054) do
t.string "name", null: false
t.boolean "publish_without_qa", default: true
t.boolean "synchronizing_publications", default: false, null: false
t.boolean "forbid_to_publish_builds_not_from", default: true, null: false
t.string "forbid_to_publish_builds_not_from"
t.index ["platform_id"], :name => "index_repositories_on_platform_id"
end