Skip to content

Commit

Permalink
[api] fix handling of service pack layered setups on branch
Browse files Browse the repository at this point in the history
* We find update areas in old layers, even when projects only link to stable ones now
* update package sources get fetched when OBS:BranchTarget for servicepack repo is used
* take devel package definitions in update projects also into account
  • Loading branch information
adrianschroeter committed Jun 17, 2015
1 parent b46731f commit 14d8c60
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
10 changes: 6 additions & 4 deletions src/api/app/helpers/branch_package.rb
Expand Up @@ -371,7 +371,7 @@ def check_for_update_project(p)
unless p[:link_target_project].is_a? Project and p[:link_target_project].find_attribute('OBS', 'BranchTarget')
p[:link_target_project] = update_project
end
update_pkg = update_project.find_package(pkg_name)
update_pkg = update_project.find_package(pkg_name, true) # true for check_update_package in older service pack projects
if update_pkg
# We have no package in the update project yet, but sources are reachable via project link
if update_project.develproject and up = update_project.develproject.find_package(pkg_name)
Expand All @@ -388,7 +388,7 @@ def check_for_update_project(p)
# The defined update project can't reach the package instance at all.
# So we need to create a new package and copy sources
params[:missingok] = 1 # implicit missingok or better report an error ?
p[:copy_from_devel] = p[:package] if p[:package].is_a? Package
p[:copy_from_devel] = p[:package].find_devel_package if p[:package].is_a? Package
p[:package] = pkg_name
end
end
Expand Down Expand Up @@ -483,8 +483,10 @@ def find_packages_to_branch
raise NotMissingError.new "Branch call with missingok paramater but branch source (#{params[:project]}/#{params[:package]}) exists."
end
else
pkg = Package.get_by_project_and_name params[:project], params[:package]
unless prj.is_a? Project and prj.find_attribute('OBS', 'BranchTarget')
pkg = Package.get_by_project_and_name params[:project], params[:package], {check_update_project: true}
if prj.is_a? Project and prj.find_attribute('OBS', 'BranchTarget')
@copy_from_devel = true
else
prj = pkg.project if pkg
end
end
Expand Down
14 changes: 10 additions & 4 deletions src/api/test/functional/maintenance_test.rb
Expand Up @@ -310,7 +310,8 @@ def test_branch_from_service_pack_WIP
get '/source/home:king:branches:ServicePack/pack2/_history'
assert_response :success
# we found the new code in update project nevertheless that ServicePack does not link to it
assert_xml_tag :tag => "comment", :content => "fetch updates from devel package BaseDistro:Update/pack2"
# and the update package even has a devel area defined here
assert_xml_tag :tag => "comment", :content => "fetch updates from devel package Devel:BaseDistro:Update/pack2"

delete '/source/ServicePack'
assert_response :success
Expand Down Expand Up @@ -1451,13 +1452,20 @@ def test_create_maintenance_project_and_release_packages
assert node.has_attribute?(:vrev)
assert_equal node.value(:vrev), "#{vrev1}.#{(vrev2.to_i+2).to_s}" # got increased by 2

# check that new packages in update project get also found
# new packages in Update project found, even we just project-link only to GA
post '/source/BaseDistro2.0:LinkedUpdateProject/packNEW?cmd=copy&oproject=BaseDistro2.0&opackage=pack2'
assert_response :success
post '/source/BaseDistro2.0:ServicePack1/packNEW?cmd=branch'
assert_response :success
delete '/source/home:king:branches:BaseDistro2.0:LinkedUpdateProject/packNEW'
assert_response :success
# same for instantiate
post '/source/BaseDistro2.0:ServicePack1/packNEW?cmd=instantiate'
assert_response :success
get '/source/BaseDistro2.0:ServicePack1/packNEW/_link'
assert_response :success
delete '/source/BaseDistro2.0:LinkedUpdateProject/packNEW'
assert_response :success

# create a new package instance via submit request the right way
delete '/source/BaseDistro2.0:ServicePack1/pack2.linked'
Expand Down Expand Up @@ -1533,8 +1541,6 @@ def test_create_maintenance_project_and_release_packages
assert_equal node.value(:vrev), "#{vrev1}.#{(vrev2.to_i+1).to_s}.2.1" # untouched

# cleanup
delete '/source/BaseDistro2.0:LinkedUpdateProject/packNEW'
assert_response :success
delete '/source/BaseDistro2.0:ServicePack1'
assert_response :success
delete "/source/#{incidentProject}"
Expand Down

0 comments on commit 14d8c60

Please sign in to comment.