debian-mirror-gitlab/app/services/design_management/runs_design_actions.rb

37 lines
1.2 KiB
Ruby
Raw Normal View History

2020-05-24 23:13:21 +05:30
# frozen_string_literal: true
module DesignManagement
module RunsDesignActions
NoActions = Class.new(StandardError)
2021-01-03 14:25:43 +05:30
# This concern requires the following methods to be implemented:
2020-05-24 23:13:21 +05:30
# current_user, target_branch, repository, commit_message
#
# Before calling `run_actions`, you should ensure the repository exists, by
# calling `repository.create_if_not_exists`.
#
# @raise [NoActions] if actions are empty
2021-01-03 14:25:43 +05:30
# @return [DesignManagement::Version]
def run_actions(actions, skip_system_notes: false)
2020-05-24 23:13:21 +05:30
raise NoActions if actions.empty?
sha = repository.multi_action(current_user,
branch_name: target_branch,
message: commit_message,
actions: actions.map(&:gitaly_action))
::DesignManagement::Version
.create_for_designs(actions, sha, current_user)
2021-01-03 14:25:43 +05:30
.tap { |version| post_process(version, skip_system_notes) }
2020-05-24 23:13:21 +05:30
end
private
2021-01-03 14:25:43 +05:30
def post_process(version, skip_system_notes)
2020-05-24 23:13:21 +05:30
version.run_after_commit_or_now do
2021-01-03 14:25:43 +05:30
::DesignManagement::NewVersionWorker.perform_async(id, skip_system_notes)
2020-05-24 23:13:21 +05:30
end
end
end
end