Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[api] allow to release a flavor only via request action #16665

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions src/api/app/models/bs_request_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
errors.add(:target_package, 'No source changes are allowed, if source and target is identical') if source_package == target_package && source_project == target_project && (sourceupdate || updatelink)
end
errors.add(:target_package, 'is invalid package name') if target_package && !Package.valid_name?(target_package)
errors.add(:source_package, 'is invalid package name') if source_package && !Package.valid_name?(source_package)
errors.add(:source_package, 'is invalid package name') if source_package && !Package.valid_name?(Package.striping_multibuild_suffix(source_package))
errors.add(:target_project, 'is invalid project name') if target_project && !Project.valid_name?(target_project)
errors.add(:source_project, 'is invalid project name') if source_project && !Project.valid_name?(source_project)
errors.add(:source_rev, 'should not be upload') if source_rev == 'upload'
Expand Down Expand Up @@ -707,6 +707,12 @@
return
end

# allow to release flavors only
if action_type.in?(%i[release]) && source_package&.include?(':')
Package.get_by_project_and_name(source_project, source_package, { follow_multibuild: true })
return

Check warning on line 713 in src/api/app/models/bs_request_action.rb

View check run for this annotation

Codecov / codecov/patch

src/api/app/models/bs_request_action.rb#L712-L713

Added lines #L712 - L713 were not covered by tests
end

if action_type.in?(%i[submit release maintenance_release maintenance_incident])
packages = []
if source_package
Expand Down Expand Up @@ -739,7 +745,7 @@
end

def source_access_check!
sp = Package.find_by_project_and_name(source_project, source_package)
sp = Package.find_by_project_and_name(source_project, Package.striping_multibuild_suffix(source_package))
if sp.nil?
# either not there or read permission problem
if Package.exists_on_backend?(source_package, source_project)
Expand All @@ -749,7 +755,7 @@
tprj = Project.find_by_name(target_project)
if tprj.nil? || !User.possibly_nobody.can_modify?(tprj)
# produce an error for the source
Package.get_by_project_and_name(source_project, source_package)
Package.get_by_project_and_name(source_project, source_package, { follow_multibuild: true })
end
return
end
Expand All @@ -759,7 +765,7 @@
end

# produce the same exception for webui
Package.get_by_project_and_name(source_project, source_package)
Package.get_by_project_and_name(source_project, source_package, { follow_multibuild: true })

Check warning on line 768 in src/api/app/models/bs_request_action.rb

View check run for this annotation

Codecov / codecov/patch

src/api/app/models/bs_request_action.rb#L768

Added line #L768 was not covered by tests
end
if sp.instance_of?(String)
# a remote package
Expand Down Expand Up @@ -829,7 +835,7 @@
end

def commit_details
package = Package.find_by_project_and_name(source_project, source_package)
package = Package.find_by_project_and_name(source_project, Package.striping_multibuild_suffix(source_package))

Check warning on line 838 in src/api/app/models/bs_request_action.rb

View check run for this annotation

Codecov / codecov/patch

src/api/app/models/bs_request_action.rb#L838

Added line #L838 was not covered by tests

return nil if package.nil? || source_rev.nil?

Expand Down Expand Up @@ -942,7 +948,7 @@
raise NotSupported, "Source project #{source_project} is not a local project. This is not supported yet." unless sprj.instance_of?(Project) || action_type.in?(%i[submit maintenance_incident])

if source_package
spkg = Package.get_by_project_and_name(source_project, source_package)
spkg = Package.get_by_project_and_name(source_project, source_package, { follow_multibuild: true })
spkg.check_weak_dependencies! if spkg && sourceupdate == 'cleanup'
end

Expand Down Expand Up @@ -1000,7 +1006,7 @@
def check_permissions_for_sources!
return unless sourceupdate.in?(%w[update cleanup]) || updatelink

source_object = Package.find_by_project_and_name(source_project, source_package) ||
source_object = Package.find_by_project_and_name(source_project, Package.striping_multibuild_suffix(source_package)) ||
Project.get_by_name(source_project)

raise LackingMaintainership if !source_object.is_a?(String) && !User.possibly_nobody.can_modify?(source_object)
Expand Down Expand Up @@ -1031,7 +1037,7 @@
end

def source_package_object
@source_package_object ||= Package.find_by_project_and_name(source_project, source_package)
@source_package_object ||= Package.find_by_project_and_name(source_project, Package.striping_multibuild_suffix(source_package))

Check warning on line 1040 in src/api/app/models/bs_request_action.rb

View check run for this annotation

Codecov / codecov/patch

src/api/app/models/bs_request_action.rb#L1040

Added line #L1040 was not covered by tests
end

def source_project_object
Expand Down
10 changes: 8 additions & 2 deletions src/api/app/models/bs_request_action_release.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,17 @@
end

def execute_accept(opts)
pkg = Package.get_by_project_and_name(source_project, source_package)
pkg = Package.get_by_project_and_name(source_project, source_package, follow_multibuild: true)

# have a unique time stamp for release
opts[:acceptTimeStamp] ||= Time.zone.now

release_package(pkg, Project.get_by_name(target_project), target_package, { action: self, manual: true })
flags = { action: self, manual: true }
target_package ||= Package.striping_multibuild_suffix(source_package)
if source_package.include?(':') && !source_package.starts_with?('_product:')
flags[:multibuild_container] = source_package.gsub(/^.*:/, '')

Check warning on line 46 in src/api/app/models/bs_request_action_release.rb

View check run for this annotation

Codecov / codecov/patch

src/api/app/models/bs_request_action_release.rb#L46

Added line #L46 was not covered by tests
end
release_package(pkg, Project.get_by_name(target_project), target_package, flags)
end

def check_permissions!
Expand All @@ -50,6 +55,7 @@
# For consistency reasons with the other BsRequestActions
# rubocop:disable Naming/AccessorMethodName
def set_acceptinfo(acceptinfo)
target_package ||= Package.striping_multibuild_suffix(source_package)
# released packages are expanded copies, so we can not use
# the link information. We need to patch the "old" part
base_package_name = target_package.gsub(/\.[^.]*$/, '')
Expand Down
3 changes: 3 additions & 0 deletions src/api/app/models/concerns/multibuild_package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ def valid_multibuild_name?(name)
end

def striping_multibuild_suffix(name)
# webui is not checking if object exists
return nil if name.nil?

# exception for package names used to have a collon
return name if name.start_with?('_patchinfo:', '_product:')

Expand Down