Skip to content

Commit

Permalink
Merge pull request #9112 from vpereira/create_expand_package_refactoring
Browse files Browse the repository at this point in the history
Create expand package refactoring
  • Loading branch information
vpereira committed Feb 22, 2020
2 parents f4736f6 + 458bb5f commit 1b9c826
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 98 deletions.
40 changes: 19 additions & 21 deletions src/api/app/models/bs_request_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -542,13 +542,10 @@ def create_expand_package(packages, opts = {})
new_action.source_rev = rev if rev
if is_maintenance_release?
if pkg.is_channel?

# create submit request for possible changes in the _channel file
submit_action = BsRequestActionSubmit.new
submit_action.source_project = new_action.source_project
submit_action.source_package = new_action.source_package
submit_action.source_rev = new_action.source_rev
submit_action.target_project = tprj.name
submit_action.target_package = tpkg
submit_action = create_submit_action(source_package: new_action.source_package, source_project: new_action.source_project,
target_package: tpkg, target_project: tprj.name, source_rev: new_action.source_rev)
# replace the new action
new_action.destroy
new_action = submit_action
Expand Down Expand Up @@ -577,29 +574,19 @@ def create_expand_package(packages, opts = {})
new_targets.uniq!
new_packages.uniq!
new_packages.each do |pkg|
release_targets = nil
if pkg.is_patchinfo?
release_targets = Patchinfo.new.fetch_release_targets(pkg)
end
new_targets.each do |p|
release_targets = pkg.is_patchinfo? ? Patchinfo.new.fetch_release_targets(pkg) : nil
new_targets.each do |new_target_project|
if release_targets.present?
found = false
release_targets.each do |rt|
if rt['project'] == p
found = true
break
end
end
next unless found
next unless release_targets.any? { |rt| rt['project'] == new_target_project }
end

# skip if there is no active maintenance trigger for this package
next if is_maintenance_incident? && !maintenance_trigger?(pkg.project.repositories, Project.find_by_name(p).repositories)
next if is_maintenance_incident? && !maintenance_trigger?(pkg.project.repositories, Project.find_by_name(new_target_project).repositories)

new_action = dup
new_action.source_package = pkg.name
unless is_maintenance_incident?
new_action.target_project = p
new_action.target_project = new_target_project
new_action.target_package = pkg.name + incident_suffix
end
newactions << new_action
Expand Down Expand Up @@ -778,6 +765,17 @@ def set_sourceupdate_default(user)

private

def create_submit_action(source_package:, source_project:, target_package:, target_project:,
source_rev:)
submit_action = BsRequestActionSubmit.new
submit_action.source_package = source_package
submit_action.source_project = source_project
submit_action.target_package = target_package
submit_action.target_project = target_project
submit_action.source_rev = source_rev
submit_action
end

def check_patchinfo(pkg)
pkg.project.repositories.collect do |repo|
firstarch = repo.architectures.first
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions src/api/spec/models/bs_request_action_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,19 @@
describe 'create_expand_package' do
before do
allow(User).to receive(:session!).and_return(user)
allow(Backend::Api::BuildResults::Binaries).to receive(:files).and_return(binary_list)
allow(Backend::Api::BuildResults::Binaries).to receive(:history).and_return(build_history)
allow(Directory).to receive(:hashed).and_return(hashed)
end

let(:hashed) do
{
'linkinfo' => { 'project' => target_prj.name, 'package' => target_pkg.name,
'srcmd5' => 'aaee591c4043f45e369dd8b022ce1a7b',
'xsrcmd5' => 'ab6a14a292165f7f9eb012fc9528224a',
'lsrcmd5' => '683e6f3cee9a19e1e839dcc61cbc6256' },
'srcmd5' => 'ef521827053c2e3b3cc735662c5d5bb0'
}
end

let(:binary_list) do
Expand Down

0 comments on commit 1b9c826

Please sign in to comment.