#394: Forbid to publish builds not from valid branch

This commit is contained in:
Vokhmin Alexey V 2014-05-29 00:18:29 +04:00
parent 8cfc2b24f7
commit 2200c19189
7 changed files with 43 additions and 8 deletions

View File

@ -392,7 +392,14 @@ class BuildList < ActiveRecord::Base
end
def can_publish?
[SUCCESS, FAILED_PUBLISH, BUILD_PUBLISHED, TESTS_FAILED, BUILD_PUBLISHED_INTO_TESTING, FAILED_PUBLISH_INTO_TESTING].include?(status) && extra_build_lists_published? && save_to_repository.projects.exists?(id: project_id)
super &&
valid_branch_for_publish? &&
extra_build_lists_published? &&
save_to_repository.projects.exists?(id: project_id)
end
def can_publish_into_testing?
super && valid_branch_for_publish?
end
def extra_build_lists_published?
@ -597,6 +604,16 @@ class BuildList < ActiveRecord::Base
protected
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? )
p.repo.git.native(:branch, {}, '--contains', commit_hash).
gsub(/\*/, '').split(/\n/).map(&:strip).include?(save_to_platform.name)
end
def create_container
AbfWorker::BuildListsPublishTaskManager.create_container_for self
end

View File

@ -29,7 +29,12 @@ class Repository < ActiveRecord::Base
before_destroy :detele_directory
attr_accessible :name, :description, :publish_without_qa, :synchronizing_publications
attr_accessible :name,
:description,
:publish_without_qa,
:synchronizing_publications,
:forbid_to_publish_builds_not_from
attr_readonly :name, :platform_id
attr_accessor :projects_list

View File

@ -11,6 +11,11 @@
.leftlist= f.label :synchronizing_publications
.rightlist= f.check_box :synchronizing_publications
- 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
.both
.hr

View File

@ -71,3 +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"

View File

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

View File

@ -0,0 +1,5 @@
class AddForbidToPublishBuildsNotFromToRepositories < ActiveRecord::Migration
def change
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: 20140523192643) do
ActiveRecord::Schema.define(version: 20140528170054) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -522,13 +522,14 @@ ActiveRecord::Schema.define(version: 20140523192643) do
end
create_table "repositories", force: true do |t|
t.string "description", null: false
t.integer "platform_id", null: false
t.string "description", null: false
t.integer "platform_id", null: false
t.datetime "created_at"
t.datetime "updated_at"
t.string "name", null: false
t.boolean "publish_without_qa", default: true
t.boolean "synchronizing_publications", default: false, null: false
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.index ["platform_id"], :name => "index_repositories_on_platform_id"
end