Merge pull request #455 from abf/rosa-build:default-branch-for-platforms
Add ability to use specific branch for each platform
This commit is contained in:
commit
921e12e7cb
|
@ -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()
|
||||
|
|
|
@ -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?
|
||||
|
||||
|
||||
|
|
|
@ -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) )
|
||||
}
|
||||
|
|
|
@ -67,6 +67,10 @@ class Platform < ActiveRecord::Base
|
|||
format: { with: /\A#{NAME_PATTERN}\z/ },
|
||||
length: { maximum: 100 }
|
||||
|
||||
validates :default_branch,
|
||||
presence: true,
|
||||
length: { maximum: 100 }
|
||||
|
||||
validates :distrib_type,
|
||||
presence: true,
|
||||
inclusion: { in: APP_CONFIG['distr_types'] }
|
||||
|
@ -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
|
||||
|
||||
|
|
|
@ -210,10 +210,10 @@ class Project < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def project_version_for(save_to_platform, build_for_platform)
|
||||
if repo.commits("#{save_to_platform.name}").try(:first).try(:id)
|
||||
save_to_platform.name
|
||||
elsif repo.commits("#{build_for_platform.name}").try(:first).try(:id)
|
||||
build_for_platform.name
|
||||
if repo.commits("#{save_to_platform.default_branch}").try(:first).try(:id)
|
||||
save_to_platform.default_branch
|
||||
elsif repo.commits("#{build_for_platform.default_branch}").try(:first).try(:id)
|
||||
build_for_platform.default_branch
|
||||
else
|
||||
default_branch
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -100,7 +100,12 @@ en:
|
|||
platform:
|
||||
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.
|
||||
default_branch: Enter the name of branch here.
|
||||
|
||||
|
|
|
@ -101,6 +101,12 @@ ru:
|
|||
platform:
|
||||
term: Искать
|
||||
admin_id: Владелец
|
||||
default_branch: Ветка по умолчанию
|
||||
hints:
|
||||
platform:
|
||||
default_branch: "Это имя ветки, которая будет использоваться по умолчанию при создании сборок для платформы."
|
||||
placeholders:
|
||||
platform:
|
||||
term: Введите имя файла или папки здесь.
|
||||
default_branch: Введите имя ветки здесь.
|
||||
|
||||
|
|
|
@ -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
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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) }
|
||||
|
|
Loading…
Reference in New Issue