Skip to content

Commit

Permalink
Merge pull request #13813 from krauselukas/fix/issue_13338
Browse files Browse the repository at this point in the history
Reject set_flags step when restoring projects after a PR was reopend
  • Loading branch information
krauselukas authored Feb 9, 2023
2 parents a3fabcd + ab4f71c commit 9d8c123
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/api/app/models/workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class Workflow
}.freeze

SUPPORTED_FILTERS = [:branches, :event].freeze
STEPS_WITH_NO_TARGET_PROJECT_TO_RESTORE_OR_DESTROY = [Workflow::Step::ConfigureRepositories, Workflow::Step::RebuildPackage,
Workflow::Step::SetFlags].freeze

attr_accessor :workflow_instructions, :scm_webhook, :token, :workflow_run

Expand Down Expand Up @@ -114,9 +116,7 @@ def branch_matches_branches_filter?
# TODO: Extract this into a service
def destroy_target_projects
# Do not process steps for which there's nothing to do
processable_steps = steps.reject do |step|
step.instance_of?(::Workflow::Step::ConfigureRepositories) || step.instance_of?(::Workflow::Step::RebuildPackage) || step.instance_of?(::Workflow::Step::SetFlags)
end
processable_steps = steps.reject { |step| step.class.in?(STEPS_WITH_NO_TARGET_PROJECT_TO_RESTORE_OR_DESTROY) }
target_packages = processable_steps.map(&:target_package).uniq.compact
EventSubscription.where(channel: 'scm', token: token, package: target_packages).delete_all

Expand All @@ -130,7 +130,7 @@ def restore_target_projects
token_user_login = token.executor.login

# Do not process steps for which there's nothing to do
processable_steps = steps.reject { |step| step.instance_of?(::Workflow::Step::ConfigureRepositories) || step.instance_of?(::Workflow::Step::RebuildPackage) }
processable_steps = steps.reject { |step| step.class.in?(STEPS_WITH_NO_TARGET_PROJECT_TO_RESTORE_OR_DESTROY) }
target_project_names = processable_steps.map(&:target_project_name).uniq.compact
target_project_names.each do |target_project_name|
Project.restore(target_project_name, user: token_user_login)
Expand Down

0 comments on commit 9d8c123

Please sign in to comment.