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] release action: support specification of source repository #16883

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
5 changes: 5 additions & 0 deletions docs/api/api/request.rng
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@
<data type="string" />
</attribute>
</optional>
<optional>
<attribute name="repository">
<data type="string" />
</attribute>
</optional>
<empty/>
</element>
</optional>
Expand Down
4 changes: 4 additions & 0 deletions src/api/app/models/bs_request_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/api/app/models/bs_request_action_add_role.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/api/app/models/bs_request_action_change_devel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/api/app/models/bs_request_action_delete.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 19 additions & 1 deletion src/api/app/models/bs_request_action_release.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down Expand Up @@ -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?

Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/api/app/models/bs_request_action_set_bugowner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/api/app/models/bs_request_action_submit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion src/api/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down