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

Handle project sources in a consistent fashion #16928

Closed
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
9 changes: 7 additions & 2 deletions src/api/app/controllers/source_project_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class SourceProjectController < SourceController
# GET /source/:project
def show
project_name = params[:project]
if params.key?(:deleted)
if params[:deleted] == '1'
unless Project.find_by_name(project_name) || Project.is_remote_project?(project_name)
# project is deleted or not accessible
validate_visibility_of_deleted_project(project_name)
Expand All @@ -22,6 +22,10 @@ def show
@project = Project.find_by_name(project_name)
raise Project::UnknownObjectError, "Project not found: #{project_name}" unless @project

pass_to_backend

return if @project.scmsync.present?

# we let the backend list the packages after we verified the project is visible
if params.key?(:view)
case params[:view]
Expand Down Expand Up @@ -52,7 +56,8 @@ def render_project_issues
end

def render_project_packages
@packages = params.key?(:expand) ? @project.expand_all_packages : @project.packages.pluck(:name)
# TODO: Display multibuild flavors when passing the expand param
@packages = params.key?(:expand) ? @project.expand_all_packages : @project.packages.sort_by(&:name)
render locals: { expand: params.key?(:expand) }, formats: [:xml]
end

Expand Down
11 changes: 8 additions & 3 deletions src/api/app/views/source_project/show.xml.builder
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
xml.directory(count: @packages.count) do
@packages.map do |name, project|
@packages.map do |package, project|
if expand
xml.entry(name: name, originproject: project)
xml.entry(name: package, originproject: project)
elsif package.multibuild?
xml.entry(name: package.name)
package.multibuild_flavors.each do |flavor|
xml.entry(name: "#{package.name}:#{flavor}", originpackage: package.name)
end
else
xml.entry(name: name)
xml.entry(name: package)
end
end
end
4 changes: 4 additions & 0 deletions src/api/test/functional/channel_maintenance_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@ def test_large_channel_test
get '/source/' + incident_project + '/pack2.BaseDistro2.0_LinkedUpdateProject/_meta'
assert_response :success
assert_xml_tag tag: 'releasename', content: 'pack2'
put '/source/' + incident_project + '/pack2.linked.BaseDistro2.0_LinkedUpdateProject/_multibuild', params: '<multibuild><flavor>A</flavor></multibuild>'
assert_response :success
get '/source/' + incident_project + '/pack2.linked.BaseDistro2.0_LinkedUpdateProject/_multibuild'
assert_response :success
get '/source/' + incident_project + '/pack2.linked.BaseDistro2.0_LinkedUpdateProject/_meta'
assert_response :success
assert_xml_tag tag: 'releasename', content: 'pack2.linked'
Expand Down