debian-mirror-gitlab/app/services/files/multi_service.rb

33 lines
738 B
Ruby
Raw Normal View History

2016-11-03 12:29:30 +05:30
module Files
class MultiService < Files::BaseService
2017-08-17 22:00:37 +05:30
def create_commit!
2016-11-03 12:29:30 +05:30
repository.multi_action(
user: current_user,
message: @commit_message,
2017-08-17 22:00:37 +05:30
branch_name: @branch_name,
2016-11-03 12:29:30 +05:30
actions: params[:actions],
author_email: @author_email,
2017-08-17 22:00:37 +05:30
author_name: @author_name,
start_project: @start_project,
start_branch_name: @start_branch
2016-11-03 12:29:30 +05:30
)
end
private
2017-08-17 22:00:37 +05:30
def validate!
2016-11-03 12:29:30 +05:30
super
2017-08-17 22:00:37 +05:30
params[:actions].each do |action|
validate_action!(action)
2016-11-03 12:29:30 +05:30
end
end
2017-08-17 22:00:37 +05:30
def validate_action!(action)
unless Gitlab::Git::Index::ACTIONS.include?(action[:action].to_s)
raise_error("Unknown action '#{action[:action]}'")
2016-11-03 12:29:30 +05:30
end
end
end
end