Skip to content

Commit

Permalink
[api] support explicit parameter to get a new branch of a package
Browse files Browse the repository at this point in the history
newinstance=1 is keeping the link target. To be used to instantiate a
new package instance for service packs.
  • Loading branch information
adrianschroeter committed Jul 21, 2015
1 parent a56adb4 commit bafe316
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/api/api/api.txt
Expand Up @@ -619,6 +619,7 @@ Parameters:
target_package: target package name, optional
noaccess: the new created project will be read protected, bool, optional
missingok: the target package does not exist
newinstance: the target package exists only via project links, but the link should point to given project
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
Expand Down
5 changes: 5 additions & 0 deletions src/api/app/helpers/branch_package.rb
Expand Up @@ -328,6 +328,11 @@ def determine_details_about_package_to_branch(p)
end
end

if params[:newinstance]
# user explicit wants this link target
p[:link_target_project] = Project.get_by_name params[:project]
end

# set default based on first found package location
unless @target_project
@target_project = "home:#{User.current.login}:branches:#{p[:link_target_project].name}"
Expand Down
33 changes: 33 additions & 0 deletions src/api/test/functional/maintenance_test.rb
Expand Up @@ -14,6 +14,39 @@ def setup
Timecop.return
end

def test_instantiate_for_service_packs
login_tom
# add a new package with defined link target
put '/source/home:tom:BaseDistro:SP1/_meta',
'<project name="home:tom:BaseDistro:SP1" kind="maintenance_release">
<title/> <description/>
<link project="BaseDistro:Update"/>
</project>'
assert_response :success

post '/source/home:tom:BaseDistro:SP1/pack1', :cmd => 'branch', :target_project => 'home:tom:Branch', :missingok => 1
assert_response 400
# osc catches this error code and is fallingback to newinstance=1
assert_xml_tag tag: 'status', attributes: {code: "not_missing"}

post '/source/home:tom:BaseDistro:SP1/pack1', :cmd => 'branch', :target_project => 'home:tom:Branch', :newinstance => 1
assert_response :success
assert_xml_tag tag: 'data', attributes: {name: "sourceproject"}, content: "home:tom:BaseDistro:SP1"

get "/source/home:tom:Branch/pack1/_link"
assert_response :success
assert_xml_tag tag: 'link', attributes: {project: "home:tom:BaseDistro:SP1"}

post '/source/BaseDistro:Update/pack1', :cmd => 'branch', :target_project => 'home:tom:Branch', :missingok => 1, :extend_package_names => 1
assert_response 400
assert_xml_tag tag: 'status', attributes: {code: "not_missing"}

delete "/source/home:tom:Branch"
assert_response :success
delete "/source/home:tom:BaseDistro:SP1"
assert_response :success
end

def test_create_maintenance_project
login_tom

Expand Down
1 change: 1 addition & 0 deletions src/api/test/unit/code_quality_test.rb
Expand Up @@ -72,6 +72,7 @@ def setup
'BranchPackage#find_packages_to_branch' => 234.73,
'BranchPackage#create_branch_packages' => 214.0,
'BranchPackage#check_for_update_project' => 101.04,
'BranchPackage#determine_details_about_package_to_branch' => 81.6,
'BranchPackage#lookup_incident_pkg' => 80.64,
'BsRequest#change_review_state' => 203.53,
'BsRequest#changestate_accepted' => 80.21,
Expand Down

0 comments on commit bafe316

Please sign in to comment.