diff --git a/docs/api/api/request.rng b/docs/api/api/request.rng index b335583fb32..330ba410c28 100644 --- a/docs/api/api/request.rng +++ b/docs/api/api/request.rng @@ -89,6 +89,11 @@ + + + + + diff --git a/src/api/app/models/bs_request_action.rb b/src/api/app/models/bs_request_action.rb index efa51f3f0e2..a944b13b047 100644 --- a/src/api/app/models/bs_request_action.rb +++ b/src/api/app/models/bs_request_action.rb @@ -121,6 +121,7 @@ def store_from_xml(hash) self.source_package = source.delete('package') self.source_project = source.delete('project') self.source_rev = source.delete('rev') + self.source_repository = source.delete('repository') raise ArgumentError, "too much information #{source.inspect}" if source.present? end @@ -224,6 +225,7 @@ def notify_params(ret = {}) ret[:sourceproject] = source_project ret[:sourcepackage] = source_package ret[:sourcerevision] = source_rev + ret[:sourcerepository] = source_repository ret[:person] = person_name ret[:group] = group_name ret[:role] = role @@ -1026,6 +1028,7 @@ def find_reviewers(obj, disable_project: false) def render_xml_source(node) attributes = xml_package_attributes('source') attributes[:rev] = source_rev if source_rev.present? + attributes[:repository] = source_repository if source_repository.present? node.source(attributes) end @@ -1056,6 +1059,7 @@ def set_target_associations # role :string(255) # source_package :string(255) indexed # source_project :string(255) indexed +# source_repository :string(255) # source_rev :string(255) # sourceupdate :string(255) # target_package :string(255) indexed diff --git a/src/api/app/models/bs_request_action_add_role.rb b/src/api/app/models/bs_request_action_add_role.rb index 39b7cd16c4c..c55e38b832c 100644 --- a/src/api/app/models/bs_request_action_add_role.rb +++ b/src/api/app/models/bs_request_action_add_role.rb @@ -73,6 +73,7 @@ def short_name # role :string(255) # source_package :string(255) indexed # source_project :string(255) indexed +# source_repository :string(255) # source_rev :string(255) # sourceupdate :string(255) # target_package :string(255) indexed diff --git a/src/api/app/models/bs_request_action_change_devel.rb b/src/api/app/models/bs_request_action_change_devel.rb index 8dc3a4f24e0..1d732948bf3 100644 --- a/src/api/app/models/bs_request_action_change_devel.rb +++ b/src/api/app/models/bs_request_action_change_devel.rb @@ -52,6 +52,7 @@ def short_name # role :string(255) # source_package :string(255) indexed # source_project :string(255) indexed +# source_repository :string(255) # source_rev :string(255) # sourceupdate :string(255) # target_package :string(255) indexed diff --git a/src/api/app/models/bs_request_action_delete.rb b/src/api/app/models/bs_request_action_delete.rb index eb38708e638..c47c83dcedc 100644 --- a/src/api/app/models/bs_request_action_delete.rb +++ b/src/api/app/models/bs_request_action_delete.rb @@ -108,6 +108,7 @@ def remove_repository(opts) # role :string(255) # source_package :string(255) indexed # source_project :string(255) indexed +# source_repository :string(255) # source_rev :string(255) # sourceupdate :string(255) # target_package :string(255) indexed diff --git a/src/api/app/models/bs_request_action_maintenance_incident.rb b/src/api/app/models/bs_request_action_maintenance_incident.rb index 3b31bd6a926..b27f6f05fa0 100644 --- a/src/api/app/models/bs_request_action_maintenance_incident.rb +++ b/src/api/app/models/bs_request_action_maintenance_incident.rb @@ -228,6 +228,7 @@ def _merge_pkg_into_maintenance_incident(incident_project) # role :string(255) # source_package :string(255) indexed # source_project :string(255) indexed +# source_repository :string(255) # source_rev :string(255) # sourceupdate :string(255) # target_package :string(255) indexed diff --git a/src/api/app/models/bs_request_action_maintenance_release.rb b/src/api/app/models/bs_request_action_maintenance_release.rb index 45ef8e14b34..71f6d5d1cc8 100644 --- a/src/api/app/models/bs_request_action_maintenance_release.rb +++ b/src/api/app/models/bs_request_action_maintenance_release.rb @@ -186,6 +186,7 @@ def maintenance_release_cleanup(project_name) # role :string(255) # source_package :string(255) indexed # source_project :string(255) indexed +# source_repository :string(255) # source_rev :string(255) # sourceupdate :string(255) # target_package :string(255) indexed diff --git a/src/api/app/models/bs_request_action_release.rb b/src/api/app/models/bs_request_action_release.rb index de1e8dd8ee7..d68b83aca96 100644 --- a/src/api/app/models/bs_request_action_release.rb +++ b/src/api/app/models/bs_request_action_release.rb @@ -40,7 +40,20 @@ def execute_accept(opts) # 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 }) + if source_repository.present? + source_repo = Repository.find_by_project_and_name(source_project, source_repository) + raise RepositoryMissing, "Source Repository is missing #{source_project} #{source_repository}" if source_repo.empty? + flags[:filter_source_repository] = source_repo + end + target = if target_repository.present? and source_repository.present? + # only when source and target repos are defined + Repository.find_by_project_and_name(target_project, target_repository) + else + # otherwise let the release_package code do the release target definition filtering + Project.get_by_name(target_project) + end + + release_package(pkg, target, target_package, { action: self, manual: true }) end def check_permissions! @@ -89,6 +102,10 @@ def sanity_check! manual_targets = prj.repositories.includes(:release_targets).where(release_targets: { trigger: 'manual' }) raise RepositoryWithoutReleaseTarget, "Release target definition is missing in #{prj.name}" unless manual_targets.any? + if source_repository.present? + raise RepositoryMissing, "Source Repository is missing #{source_project} #{source_repository}" if Repository.find_by_project_and_name(source_project, source_repository).nil? + end + manual_targets.each do |repo| raise RepositoryWithoutArchitecture, "Repository has no architecture #{prj.name} / #{repo.name}" if repo.architectures.empty? @@ -112,6 +129,7 @@ def sanity_check! # role :string(255) # source_package :string(255) indexed # source_project :string(255) indexed +# source_repository :string(255) # source_rev :string(255) # sourceupdate :string(255) # target_package :string(255) indexed diff --git a/src/api/app/models/bs_request_action_set_bugowner.rb b/src/api/app/models/bs_request_action_set_bugowner.rb index 89604df7819..d5eabe494ed 100644 --- a/src/api/app/models/bs_request_action_set_bugowner.rb +++ b/src/api/app/models/bs_request_action_set_bugowner.rb @@ -66,6 +66,7 @@ def short_name # role :string(255) # source_package :string(255) indexed # source_project :string(255) indexed +# source_repository :string(255) # source_rev :string(255) # sourceupdate :string(255) # target_package :string(255) indexed diff --git a/src/api/app/models/bs_request_action_submit.rb b/src/api/app/models/bs_request_action_submit.rb index 25aed70be21..344e80380b4 100644 --- a/src/api/app/models/bs_request_action_submit.rb +++ b/src/api/app/models/bs_request_action_submit.rb @@ -184,6 +184,7 @@ def forward # role :string(255) # source_package :string(255) indexed # source_project :string(255) indexed +# source_repository :string(255) # source_rev :string(255) # sourceupdate :string(255) # target_package :string(255) indexed diff --git a/src/api/db/migrate/20240924121900_add_source_repository_action.rb b/src/api/db/migrate/20240924121900_add_source_repository_action.rb new file mode 100644 index 00000000000..caecd3a98f9 --- /dev/null +++ b/src/api/db/migrate/20240924121900_add_source_repository_action.rb @@ -0,0 +1,5 @@ +class AddSourceRepositoryAction < ActiveRecord::Migration[7.0] + def change + add_column :bs_request_actions, :source_repository, :string, collation: 'utf8_unicode_ci' + end +end diff --git a/src/api/db/schema.rb b/src/api/db/schema.rb index 3467a3aff6b..975504b67e6 100644 --- a/src/api/db/schema.rb +++ b/src/api/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2024_08_23_084727) do +ActiveRecord::Schema[7.0].define(version: 2024_09_24_121900) do create_table "active_storage_attachments", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| t.string "name", null: false t.string "record_type", null: false @@ -226,6 +226,7 @@ t.boolean "makeoriginolder", default: false t.integer "target_package_id" t.integer "target_project_id" + t.string "source_repository", collation: "utf8mb3_unicode_ci" t.index ["bs_request_id", "target_package_id"], name: "index_bs_request_actions_on_bs_request_id_and_target_package_id" t.index ["bs_request_id", "target_project_id"], name: "index_bs_request_actions_on_bs_request_id_and_target_project_id" t.index ["bs_request_id"], name: "bs_request_id"