2014-04-03 03:36:10 -04:00
|
|
|
module MergeRequests
|
2014-04-02 14:51:17 -04:00
|
|
|
class CreateService < MergeRequests::BaseService
|
|
|
|
def execute
|
2014-07-30 15:48:21 -04:00
|
|
|
label_params = params[:label_ids]
|
|
|
|
merge_request = MergeRequest.new(params.except(:label_ids))
|
2014-04-02 14:51:17 -04:00
|
|
|
merge_request.source_project = project
|
2014-04-03 05:05:21 -04:00
|
|
|
merge_request.target_project ||= project
|
2014-04-02 14:51:17 -04:00
|
|
|
merge_request.author = current_user
|
|
|
|
|
|
|
|
if merge_request.save
|
2014-07-30 15:48:21 -04:00
|
|
|
merge_request.update_attributes(label_ids: label_params)
|
2014-04-02 14:51:17 -04:00
|
|
|
event_service.open_mr(merge_request, current_user)
|
|
|
|
notification_service.new_merge_request(merge_request, current_user)
|
|
|
|
merge_request.create_cross_references!(merge_request.project, current_user)
|
|
|
|
execute_hooks(merge_request)
|
|
|
|
end
|
|
|
|
|
|
|
|
merge_request
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|