Added ability to use specific branch for each platform

This commit is contained in:
Vokhmin Alexey V 2015-02-18 01:33:58 +03:00
parent 86c6fa60dd
commit 7efe8894ff
10 changed files with 44 additions and 13 deletions

View File

@ -12,7 +12,7 @@ NewBuildListController = (dataservice, $http) ->
result = _.select(vm.save_to_repositories, (e) ->
e.id is vm.save_to_repository_id or
!vm.save_to_repository_id and
e.platform_name is vm.project_version_name
e.default_branch is vm.project_version_name
)
return vm.save_to_repositories[0] if result.length is 0
result[0]
@ -78,7 +78,7 @@ NewBuildListController = (dataservice, $http) ->
vm.build_for_platform_id = vm.save_to_repository.platform_id
vm.is_build_for_main_platform = isBuildForMainPlatform()
vm.project_version_name = vm.save_to_repository.platform_name
vm.project_version_name = vm.save_to_repository.default_branch
vm.project_version = setProjectVersion() if vm.is_build_for_main_platform
changeStatusRepositories()

View File

@ -51,7 +51,7 @@ class Platforms::PlatformsController < Platforms::BaseController
@admin_uname = params[:admin_uname]
platform_params = params[:platform] || {}
platform_params = platform_params.slice(:description, :platform_arch_settings_attributes, :released, :automatic_metadata_regeneration)
platform_params = platform_params.slice(:description, :platform_arch_settings_attributes, :released, :automatic_metadata_regeneration, :default_branch)
platform_params[:owner] = User.find(@admin_id) if @admin_id.present?

View File

@ -222,7 +222,7 @@ module BuildListsHelper
publish_without_qa: r.publish_without_qa?,
repo_name: r.name,
platform_id: r.platform.id,
platform_name: r.platform.name,
default_branch: r.platform.default_branch,
default_arches: ( r.platform.platform_arch_settings.by_default.pluck(:arch_id).presence ||
Arch.where(name: Arch::DEFAULT).pluck(:id) )
}

View File

@ -65,7 +65,11 @@ class Platform < ActiveRecord::Base
uniqueness: { case_sensitive: false },
presence: true,
format: { with: /\A#{NAME_PATTERN}\z/ },
length: { maximum: 100 }
length: { maximum: 100 }
validates :default_branch,
presence: true,
length: { maximum: 100 }
validates :distrib_type,
presence: true,
@ -114,7 +118,8 @@ class Platform < ActiveRecord::Base
:platform_arch_settings_attributes,
:automatic_metadata_regeneration,
:admin_id,
:term
:term,
:default_branch
attr_accessor :admin_id, :term

View File

@ -22,6 +22,8 @@
value: @admin_uname,
class: 'typeahead' }
= f.input :default_branch
- if %w(edit update).include? controller.action_name
- if can? :change_visibility, @platform

View File

@ -98,9 +98,14 @@ en:
simple_form:
labels:
platform:
term: Search
admin_id: Owner
term: Search
admin_id: Owner
default_branch: Default branch
hints:
platform:
default_branch: "This is the name of branch that will be used by default at creation of build for platform."
placeholders:
platform:
term: Enter the name of file or folder here.
term: Enter the name of file or folder here.
default_branch: Enter the name of branch here.

View File

@ -99,8 +99,14 @@ ru:
simple_form:
labels:
platform:
term: Искать
admin_id: Владелец
term: Искать
admin_id: Владелец
default_branch: Ветка по умолчанию
hints:
platform:
default_branch: "Это имя ветки, которая будет использоваться по умолчанию при создании сборок для платформы."
placeholders:
platform:
term: Введите имя файла или папки здесь.
term: Введите имя файла или папки здесь.
default_branch: Введите имя ветки здесь.

View File

@ -0,0 +1,11 @@
class AddDefaultBranchToPlatforms < ActiveRecord::Migration
def up
add_column :platforms, :default_branch, :string
execute "UPDATE platforms SET default_branch = name"
change_column_null :platforms, :default_branch, false
end
def down
remove_column :platforms, :default_branch
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: 20150210192749) do
ActiveRecord::Schema.define(version: 20150217215529) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -416,6 +416,7 @@ ActiveRecord::Schema.define(version: 20150210192749) do
t.integer "last_regenerated_status"
t.string "last_regenerated_log_sha1"
t.string "automatic_metadata_regeneration"
t.string "default_branch", null: false
t.index ["name"], :name => "index_platforms_on_name", :unique => true, :case_sensitive => false
end

View File

@ -18,6 +18,7 @@ describe Platform do
it { should validate_uniqueness_of(:name).case_insensitive }
it { should allow_value('Basic_platform-name-1234').for(:name) }
it { should_not allow_value('.!').for(:name) }
it { should validate_presence_of(:default_branch)}
it { should validate_presence_of(:description) }
it { should validate_presence_of(:distrib_type) }
it { should validate_presence_of(:visibility) }