Skip to content

Commit

Permalink
Merge pull request #6622 from coolo/remove_expand_flags
Browse files Browse the repository at this point in the history
Remove expand_flags from project
  • Loading branch information
bgeuken committed Dec 16, 2018
2 parents a52511c + f374dde commit f7f865c
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 118 deletions.
4 changes: 0 additions & 4 deletions src/api/app/models/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -865,10 +865,6 @@ def activity
activity_index * 2.3276**((updated_at_was.to_f - Time.now.to_f) / 10_000_000)
end

def expand_flags
project.expand_flags(self)
end

define_method :get_flags, GetFlags.instance_method(:get_flags)
define_method :specified_flags, GetFlags.instance_method(:specified_flags)

Expand Down
78 changes: 0 additions & 78 deletions src/api/app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -680,84 +680,6 @@ def to_axml_id
"<project name='#{::Builder::XChar.encode(name)}'/>\n"
end

# calculate enabled/disabled per repo/arch
def flag_status(default, repo, arch, prj_flags, pkg_flags)
ret = default
expl = false

flags = []
if prj_flags
prj_flags.each do |f|
flags << f if f.is_relevant_for?(repo, arch)
end
end

flags.sort_by(&:specifics).each do |f|
ret = f.status
expl = f.is_explicit_for?(repo, arch)
end

flags = []
if pkg_flags
pkg_flags.each do |f|
flags << f if f.is_relevant_for?(repo, arch)
end
# in case we look at a package, the project flags are not explicit
expl = false
end

flags.sort_by(&:specifics).each do |f|
ret = f.status
expl = f.is_explicit_for?(repo, arch)
end

opts = {}
opts[:repository] = repo if repo
opts[:arch] = arch if arch
opts[:explicit] = '1' if expl
ret_str = case ret
when :enabled
'enable'
when :disabled
'disable'
else
ret
end
# we allow to only check the return value
[ret_str, opts]
end

# give out the XML for all repos/arch combos
def expand_flags(pkg = nil)
ret = {}

repos = repositories.not_remote

FlagHelper.flag_types.each do |flag_name|
pkg_flags = nil
flaglist = flags.of_type(flag_name)
pkg_flags = pkg.flags.of_type(flag_name) if pkg
flag_default = FlagHelper.default_for(flag_name)
archs = []
flagret = []
unless flag_name.in?(['lock', 'access', 'sourceaccess'])
repos.each do |repo|
flagret << flag_status(flag_default, repo.name, nil, flaglist, pkg_flags)
repo.architectures.each do |arch|
flagret << flag_status(flag_default, repo.name, arch.name, flaglist, pkg_flags)
archs << arch.name
end
end
archs.uniq.each do |arch|
flagret << flag_status(flag_default, nil, arch, flaglist, pkg_flags)
end
end
flagret << flag_status(flag_default, nil, nil, flaglist, pkg_flags)
ret[flag_name] = flagret
end
ret
end

define_method :get_flags, GetFlags.instance_method(:get_flags)
define_method :specified_flags, GetFlags.instance_method(:specified_flags)

Expand Down
13 changes: 0 additions & 13 deletions src/api/spec/models/project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -590,17 +590,4 @@ def reset_project_in_backend
expect(project_release.packages.where(name: 'my_release_target')).to exist
end
end

describe '#expand_flags' do
let!(:maintenance_incident_project) { create(:maintenance_incident_project) }
it {
expect(maintenance_incident_project.expand_flags).to eq('lock' => [['disable', {}]],
'build' => [['disable', { explicit: '1' }]],
'publish' => [['disable', { explicit: '1' }]],
'debuginfo' => [['disable', {}]],
'useforbuild' => [['enable', {}]],
'binarydownload' => [['enable', {}]],
'sourceaccess' => [['enable', {}]], 'access' => [['enable', {}]])
}
end
end
23 changes: 0 additions & 23 deletions src/api/test/functional/source_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3783,13 +3783,6 @@ def test_project_set_flag
assert_response :success
original = @response.body

assert_equal([['enable', { repository: '10.2' }],
['disable', { repository: '10.2', arch: 'i586', explicit: '1' }],
['disable', { repository: '10.2', arch: 'x86_64', explicit: '1' }],
['enable', { arch: 'i586' }],
['enable', { arch: 'x86_64' }],
['enable', {}]], projects(:home_Iggy).expand_flags['build'])

post '/source/home:unknown?cmd=set_flag&repository=10.2&arch=i586&flag=build'
assert_response 404

Expand Down Expand Up @@ -3820,14 +3813,6 @@ def test_project_set_flag
get '/source/home:Iggy/_meta'
assert_not_equal original, @response.body

# while the actual _meta changed, the expanded flags only show existing repos
assert_equal([['enable', { repository: '10.2' }],
['disable', { repository: '10.2', arch: 'i586', explicit: '1' }],
['disable', { repository: '10.2', arch: 'x86_64', explicit: '1' }],
['enable', { arch: 'i586' }],
['enable', { arch: 'x86_64' }],
['enable', {}]], projects(:home_Iggy).expand_flags['build'])

assert_equal({ 'disable' => [{ 'arch' => 'i586', 'repository' => '10.2' },
{ 'arch' => 'x86_64', 'repository' => '10.2' }],
'enable' => { 'arch' => 'i586', 'repository' => '10.7' } },
Expand All @@ -3841,14 +3826,6 @@ def test_project_set_flag
{ 'arch' => 'x86_64', 'repository' => '10.2' }],
'enable' => [{ 'arch' => 'i586', 'repository' => '10.7' }, {}] },
Xmlhash.parse(@response.body)['build'])

assert_equal([['enable', { repository: '10.2' }],
['disable', { repository: '10.2', arch: 'i586', explicit: '1' }],
['disable', { repository: '10.2', arch: 'x86_64', explicit: '1' }],
['enable', { arch: 'i586' }],
['enable', { arch: 'x86_64' }],
['enable', { explicit: '1' }]],
projects(:home_Iggy).reload.expand_flags['build'])
end

def test_package_remove_flag
Expand Down

0 comments on commit f7f865c

Please sign in to comment.