Skip to content

Commit

Permalink
[api] do not release channel packages to release target anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianschroeter committed Mar 26, 2014
1 parent a239abc commit 5078332
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 34 deletions.
40 changes: 11 additions & 29 deletions src/api/app/models/bs_request_action.rb
Expand Up @@ -541,42 +541,24 @@ def create_expand_package(packages, opts = {})
if self.is_maintenance_incident?
newTargets << tprj.name if tprj
newAction.target_releaseproject = releaseproject.name if releaseproject
else
elsif not pkg.is_channel?
newTargets << tprj.name
newAction.target_project = tprj.name
newAction.target_package = tpkg + incident_suffix
end
newAction.source_rev = rev if rev
if self.is_maintenance_release?
if pkg.is_channel?
pkg.channels.each do |channel|
# no action if channel has no targets defined, the single release action
# will move binaries and sources to the right place in that case
next if channel.channel_targets.count == 0

# add channel targets from _channel file if defined there
channel.channel_targets.each do |target|
# do not put channel package into Channel project via release
# if it will land there via submit anyway
next if tprj == target.repository.project

releaseAction = newAction.dup
releaseAction.target_project = target.repository.project.name
releaseAction.target_package = tpkg + incident_suffix
newactions << releaseAction
end

# create submit request for possible changes in the _channel file
submitAction = BsRequestActionSubmit.new
submitAction.source_project = newAction.source_project
submitAction.source_package = newAction.source_package
submitAction.source_rev = newAction.source_rev
submitAction.target_project = tprj.name
submitAction.target_package = tpkg
# replace the new action
newAction.destroy
newAction = submitAction
end
# create submit request for possible changes in the _channel file
submitAction = BsRequestActionSubmit.new
submitAction.source_project = newAction.source_project
submitAction.source_package = newAction.source_package
submitAction.source_rev = newAction.source_rev
submitAction.target_project = tprj.name
submitAction.target_package = tpkg
# replace the new action
newAction.destroy
newAction = submitAction
else # non-channel package
unless pkg.project.can_be_released_to_project?(tprj)
raise WrongLinkedPackageSource.new "According to the source link of package #{pkg.project.name}/#{pkg.name} it would go to project #{tprj.name} which is not specified as release target."
Expand Down
30 changes: 26 additions & 4 deletions src/api/test/functional/maintenance_test.rb
Expand Up @@ -422,12 +422,14 @@ def test_mbranch_and_maintenance_per_package_request
# define one
login_king
put '/source/BaseDistro3Channel/_meta', '<project name="BaseDistro3Channel"><title/><description/>
<build><disable/></build>
<publish><enable/></publish>
<repository name="channel_repo">
<arch>i586</arch>
</repository>
</project>'
assert_response :success
put '/source/BaseDistro3Channel/_config', 'Repotype: rpm-md-legacy'
put '/source/BaseDistro3Channel/_config', "Repotype: rpm-md-legacy\nType: spec"
assert_response :success
raw_post '/source/BaseDistro3Channel/_attribute', "<attributes><attribute namespace='OBS' name='MaintenanceIdTemplate'><value>My-BaseDistro3Channel-%Y-%C</value></attribute></attributes>"
assert_response :success
Expand Down Expand Up @@ -543,11 +545,23 @@ def test_mbranch_and_maintenance_per_package_request
# submit action
assert_xml_tag :tag => 'target', :attributes => { :project=> 'Channel', :package => 'BaseDistro3'},
:parent => { :tag => 'action', :attributes => {:type => 'submit'} }
# matching release action for it
assert_xml_tag :tag => 'target', :attributes => { :project=> 'BaseDistro3Channel', :package => 'BaseDistro3.0'},
# channel package is not released
assert_no_xml_tag :tag => 'source', :attributes => { :project=> 'My:Maintenance:0', :package => 'BaseDistro3.Channel'},
:parent => { :tag => 'action', :attributes => {:type => 'maintenance_release'} }
assert_xml_tag :tag => 'target', :attributes => { :project=> 'Channel', :package => 'patchinfo.0'},
# but it has a source change, so submit action
assert_xml_tag :tag => 'source', :attributes => { :project=> 'My:Maintenance:0', :package => 'BaseDistro3.Channel'},
:parent => { :tag => 'action', :attributes => {:type => 'submit'} }
# no release patchinfo into channel
assert_no_xml_tag :tag => 'target', :attributes => { :project=> 'Channel', :package => 'patchinfo.0'},
:parent => { :tag => 'action', :attributes => {:type => 'maintenance_release'} }
# release of patchinfos
assert_xml_tag :tag => 'target', :attributes => { :project=> 'BaseDistro2.0:LinkedUpdateProject', :package => 'patchinfo.0'},
:parent => { :tag => 'action', :attributes => {:type => 'maintenance_release'} }
assert_xml_tag :tag => 'target', :attributes => { :project=> 'BaseDistro3', :package => 'patchinfo.0'},
:parent => { :tag => 'action', :attributes => {:type => 'maintenance_release'} }
assert_xml_tag :tag => 'target', :attributes => { :project=> 'BaseDistro3Channel', :package => 'patchinfo.0'},
:parent => { :tag => 'action', :attributes => {:type => 'maintenance_release'} }

node = ActiveXML::Node.new(@response.body)
assert node.has_attribute?(:id)
reqid = node.value(:id)
Expand All @@ -574,6 +588,14 @@ def test_mbranch_and_maintenance_per_package_request
assert_xml_tag :parent => { :tag => 'update', :attributes => { :from => 'tom', :status => 'stable', :type => 'recommended', :version => '1'} }, :tag => 'id', :content => "UpdateInfoTagNew-updateinfo-#{Time.now.utc.year.to_s}-1"

# repo is configured as legacy rpm-md, so we require short meta data file names
get "/build/BaseDistro3Channel/_result"
assert_response :success
assert_xml_tag :tag => 'result', :attributes => {
:project => "BaseDistro3Channel",
:repository => "channel_repo",
:arch => "i586",
:code => "published",
:state => "published" }
get "/published/BaseDistro3Channel/channel_repo/repodata"
assert_response :success
assert_xml_tag :tag => 'entry', :attributes => { :name =>"filelists.xml.gz" } # by createrepo
Expand Down
2 changes: 1 addition & 1 deletion src/api/test/unit/code_quality_test.rb
Expand Up @@ -84,7 +84,7 @@ def setup
'BsRequest::new_from_xml' => 126.34,
'BsRequestAction#check_action_permission!' => 217,
'BsRequestAction#check_sanity' => 78.06,
'BsRequestAction#create_expand_package' => 356.9,
'BsRequestAction#create_expand_package' => 327.77,
'BsRequestAction#default_reviewers' => 135.96,
'BsRequestAction#find_reviewers' => 61.68,
'BsRequestAction#store_from_xml' => 88.01,
Expand Down

0 comments on commit 5078332

Please sign in to comment.