From: Adrian Schröter
---
src/api/app/controllers/request_controller.rb | 63 ++++++++++++++++---------
src/api/test/functional/maintenance_test.rb | 11 ++++-
2 files changed, 50 insertions(+), 24 deletions(-)
diff --git a/src/api/app/controllers/request_controller.rb b/src/api/app/controllers/request_controller.rb
index c94c836..f2d5cb1 100644
--- a/src/api/app/controllers/request_controller.rb
+++ b/src/api/app/controllers/request_controller.rb
@@ -291,10 +291,39 @@ class RequestController < ApplicationController
newPackages = Array.new
newTargets = Array.new
packages.each do |pkg|
- # find target via linkinfo or submit to all
- data = REXML::Document.new( backend_get("/source/#{CGI.escape(pkg.db_project.name)}/#{CGI.escape(pkg.name)}") )
- e = data.elements["directory/linkinfo"]
- unless e and DbPackage.exists_by_project_and_name( e.attributes["project"], e.attributes["package"], follow_project_links=true, allow_remote_packages=true)
+ # find target via linkinfo or submit to all.
+ # FIXME: this is currently handling local project links for packages with multiple spec files.
+ # This can be removed when we handle this as shadow packages in the backend.
+ tprj = pkg.db_project.name
+ tpkg = pkg.name
+ rev=nil
+ if action.source.has_attribute? 'rev'
+ rev = action.source.rev.text
+ end
+ while tprj == pkg.db_project.name
+ data = REXML::Document.new( backend_get("/source/#{CGI.escape(tprj)}/#{CGI.escape(tpkg)}") )
+ e = data.elements["directory/linkinfo"]
+ if e
+ tprj = e.attributes["project"]
+ tpkg = e.attributes["package"]
+ if action.value("type") == "maintenance_release" and not rev
+ # maintenance_release needs the binaries, so we always use the current source
+ if e.attributes["xsrcmd5"]
+ rev=e.attributes["xsrcmd5"]
+ elsif e.attributes["srcmd5"]
+ rev=e.attributes["srcmd5"]
+ else
+ render_error :status => 400, :errorcode => 'broken_source',
+ :message => "Current sources are broken"
+ return
+ end
+ end
+ else
+ tprj = tpkg = nil
+ end
+ end
+ # Will this be a new package ?
+ unless e and DbPackage.exists_by_project_and_name( tprj, tpkg, follow_project_links=true, allow_remote_packages=true)
if action.value("type") == "maintenance_release"
newPackages << pkg.name
next
@@ -304,33 +333,21 @@ class RequestController < ApplicationController
return
end
end
- newTargets << e.attributes["project"]
- newAction = action.clone
+ newTargets << tprj
+ newAction = ActiveXML::XMLNode.new(action.dump_xml)
newAction.add_element 'target' unless newAction.has_element? 'target'
newAction.source.set_attribute("package", pkg.name)
- newAction.target.set_attribute("project", e.attributes["project"])
- newAction.target.set_attribute("package", e.attributes["package"] + incident_suffix)
- if action.value("type") == "maintenance_release" and not newAction.source.has_attribute? 'rev'
- # maintenance_release needs the binaries, so we always use the current source
- rev=nil
- if e.attributes["xsrcmd5"]
- rev=e.attributes["xsrcmd5"]
- elsif e.attributes["srcmd5"]
- rev=e.attributes["srcmd5"]
- else
- render_error :status => 400, :errorcode => 'broken_source',
- :message => "Current sources are broken"
- return
- end
- newAction.source.set_attribute("rev", rev)
- end
+ newAction.target.set_attribute("project", tprj )
+ newAction.target.set_attribute("package", tpkg + incident_suffix)
+ newAction.source.set_attribute("rev", rev) if rev
req.add_node newAction.dump_xml
end
# new packages (eg patchinfos) go to all target projects by default in maintenance requests
+ newTargets.uniq!
newPackages.each do |pkg|
newTargets.each do |p|
- newAction = action.clone
+ newAction = ActiveXML::XMLNode.new(action.dump_xml)
newAction.add_element 'target' unless newAction.has_element? 'target'
newAction.source.set_attribute("package", pkg)
newAction.target.set_attribute("project", p)
diff --git a/src/api/test/functional/maintenance_test.rb b/src/api/test/functional/maintenance_test.rb
index 3e4f4b2..dcb985a 100644
--- a/src/api/test/functional/maintenance_test.rb
+++ b/src/api/test/functional/maintenance_test.rb
@@ -110,7 +110,6 @@ class MaintenanceTests < ActionController::IntegrationTest
assert_equal ret.package.each.count, 3
# do the real mbranch for default maintained packages
- ActionController::IntegrationTest::reset_auth
prepare_request_with_user "tom", "thunder"
post "/source", :cmd => "branch", :package => "pack2", :noaccess => 1
assert_response :success
@@ -227,6 +226,11 @@ class MaintenanceTests < ActionController::IntegrationTest
assert node.has_attribute?(:id)
id = node.value(:id)
+ # validate that request is diffable (not broken)
+#FIXME2.3: maintenance team requires this support
+# post "/request/#{id}?cmd=diff", nil
+# assert_response :success
+
# store data for later checks
get "/source/home:tom:branches:OBS_Maintained:pack2/_meta"
oprojectmeta = ActiveXML::XMLNode.new(@response.body)
@@ -448,6 +452,7 @@ class MaintenanceTests < ActionController::IntegrationTest
assert_response :success
assert_no_tag( :tag => "target", :attributes => { :project => "BaseDistro2:LinkedUpdateProject", :package => "pack2" } )
assert_no_tag( :tag => "target", :attributes => { :project => "BaseDistro3", :package => "pack2" } )
+ assert_no_tag( :tag => "target", :attributes => { :project => maintenanceProject } )
assert_tag( :tag => "target", :attributes => { :project => "BaseDistro2:LinkedUpdateProject", :package => "pack2." + incidentID } )
assert_tag( :tag => "target", :attributes => { :project => "BaseDistro3", :package => "pack2." + incidentID } )
assert_tag( :tag => "target", :attributes => { :project => "BaseDistro2:LinkedUpdateProject", :package => "patchinfo." + incidentID } )
@@ -456,6 +461,10 @@ class MaintenanceTests < ActionController::IntegrationTest
assert node.has_attribute?(:id)
reqid = node.value(:id)
+ # validate that request is diffable (not broken)
+ post "/request/#{reqid}?cmd=diff", nil
+ assert_response :success
+
# source packages got locked
[ "pack2.BaseDistro2", "pack2.BaseDistro3", "patchinfo" ].each do |pack|
get "/source/#{maintenanceProject}/#{pack}/_meta"
--
1.7.7
--
To unsubscribe, e-mail: obs-commits+unsubscribe@opensuse.org
To contact the owner, e-mail: obs-commits+owner@opensuse.org