Skip to content

Commit

Permalink
Merge pull request #2508 from Ana06/rebuild
Browse files Browse the repository at this point in the history
[api][webui] Copy the rebuild strategy
  • Loading branch information
ChrisBr authored Jan 9, 2017
2 parents bff864d + 8410bd1 commit dd42021
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/api/api/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ Parameters:
add_repositories: bool, optional, adds repositories base on source project (default for new projects)
update_path_elements: bool, optional, update all path elements if needed (used repositories depend on each other)
extend_package_names: bool, optional, extends package and repository names to allow multiple instances of same package
add_repositories_rebuild: use defined rebuild policy for new repos
add_repositories_rebuild: use defined rebuild policy for new repos ("transitive", "direct" or "local") or copy it from the source project ("copy")
add_repositories_block: use defined block policy for new repos

XmlResult: status
Expand Down
1 change: 1 addition & 0 deletions src/api/app/controllers/webui/package_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ def save_new_link
package: source_package_name,
target_project: @project.name,
target_package: params[:target_package],
add_repositories_rebuild: params[:add_repositories_rebuild],
rev: revision).branch
Event::BranchCommand.create(project: source_project_name, package: source_package_name,
targetproject: @project.name, targetpackage: params[:target_package],
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/models/branch_package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def initialize(params)
@rebuild_policy = params[:add_repositories_rebuild]
@block_policy = params[:add_repositories_block]
raise InvalidArgument.new unless [nil, "all", "local", "never"].include? @block_policy
raise InvalidArgument.new unless [nil, "transitive", "direct", "local"].include? @rebuild_policy
raise InvalidArgument.new unless [nil, "transitive", "direct", "local", "copy"].include? @rebuild_policy
# copy from devel package instead branching ?
@copy_from_devel = false
@copy_from_devel = true if params[:newinstance]
Expand Down
3 changes: 2 additions & 1 deletion src/api/app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,8 @@ def add_repository_with_targets(repoName, source_repo, add_target_repos = [], op

trepo.clone_repository_from(source_repo)
trepo.rebuild = opts[:rebuild] if opts[:rebuild]
trepo.block = opts[:block] if opts[:block]
trepo.rebuild = source_repo.rebuild if opts[:rebuild] == "copy"
trepo.block = opts[:block] if opts[:block]
trepo.save

trigger = nil # no trigger is set by default
Expand Down
1 change: 1 addition & 0 deletions src/api/app/views/webui/image_templates/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
= form_tag({ controller: :package, action: :save_new_link, project: User.current.home_project_name }, method: :post, id: 'appliance_form') do
= hidden_field_tag 'linked_project', first_template.project
= hidden_field_tag 'linked_package', first_template.name
= hidden_field_tag 'add_repositories_rebuild', 'copy'
= label_tag(:target_package, 'Name your appliance', class: 'name_appliance')
%span
(Maximum of 200 characters, no blank, /, :, - or ; characters)
Expand Down
15 changes: 13 additions & 2 deletions src/api/test/functional/source_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2340,10 +2340,10 @@ def test_branch_images_repo_without_path
def test_branch_repository_with_extra_policy
login_adrian
put '/source/home:adrian:TEMP/_meta', "<project name='home:adrian:TEMP'> <title/> <description/>
<repository name='repo1'>
<repository name='repo1' rebuild='local'>
<arch>x86_64</arch>
</repository>
<repository name='repo2'>
<repository name='repo2' rebuild='transitive'>
<arch>x86_64</arch>
</repository>
<repository name='repo3'>
Expand All @@ -2365,6 +2365,17 @@ def test_branch_repository_with_extra_policy
delete '/source/home:adrian:branches:home:adrian:TEMP'
assert_response :success

# copy rebuild strategy when branching
post '/source/home:adrian:TEMP/dummy', cmd: 'branch', add_repositories: 1, add_repositories_rebuild: :copy
assert_response :success
get '/source/home:adrian:branches:home:adrian:TEMP/_meta'
assert_response :success
assert_xml_tag(tag: 'repository', attributes: {name:"repo1", rebuild: "local"})
assert_xml_tag(tag: 'repository', attributes: {name:"repo2", rebuild: "transitive"})
assert_xml_tag(tag: 'repository', attributes: {name:"repo3"})
delete '/source/home:adrian:branches:home:adrian:TEMP'
assert_response :success

# invalid policy
post '/source/home:adrian:TEMP/dummy', cmd: 'branch', add_repositories: 1, add_repositories_rebuild: :WRONG
assert_response 400
Expand Down
2 changes: 1 addition & 1 deletion src/api/test/unit/code_quality_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def setup
'User::find_with_credentials' => 101.42,
'UserLdapStrategy::render_grouplist_ldap' => 98.25,
'Webui::DriverUpdateController#save' => 91.69,
'Webui::PackageController#save_new_link' => 82.3,
'Webui::PackageController#save_new_link' => 85.63,
'Webui::PackageController#submit_request' => 110.76,
'Webui::PackageController#dependency' => 83.57,
'Webui::PatchinfoController#save' => 256.25,
Expand Down

0 comments on commit dd42021

Please sign in to comment.