debian-mirror-gitlab/app/controllers/projects/merge_requests/application_controller.rb

66 lines
1.6 KiB
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2017-09-10 17:25:29 +05:30
class Projects::MergeRequests::ApplicationController < Projects::ApplicationController
before_action :check_merge_requests_available!
before_action :merge_request
before_action :authorize_read_merge_request!
private
def merge_request
2019-09-04 21:01:54 +05:30
@issuable =
@merge_request ||=
merge_request_includes(@project.merge_requests).find_by_iid!(params[:id])
end
def merge_request_includes(association)
2019-12-21 20:55:43 +05:30
association.includes(preloadable_mr_relations) # rubocop:disable CodeReuse/ActiveRecord
end
def preloadable_mr_relations
[:metrics, :assignees, { author: :status }]
2017-09-10 17:25:29 +05:30
end
def merge_request_params
params.require(:merge_request).permit(merge_request_params_attributes)
end
def merge_request_params_attributes
[
2018-11-08 19:23:39 +05:30
:allow_collaboration,
2017-09-10 17:25:29 +05:30
:description,
:force_remove_source_branch,
:lock_version,
:milestone_id,
:source_branch,
:source_project_id,
:state_event,
2018-11-08 19:23:39 +05:30
:squash,
2017-09-10 17:25:29 +05:30
:target_branch,
:target_project_id,
:task_num,
:title,
2018-03-17 18:26:18 +05:30
:discussion_locked,
2019-03-02 22:35:43 +05:30
label_ids: [],
2019-07-31 22:56:46 +05:30
assignee_ids: [],
2020-11-24 15:15:51 +05:30
reviewer_ids: [],
2019-03-02 22:35:43 +05:30
update_task: [:index, :checked, :line_number, :line_source]
2017-09-10 17:25:29 +05:30
]
end
def set_pipeline_variables
2020-07-28 23:09:34 +05:30
@pipelines = Ci::PipelinesForMergeRequestFinder
.new(@merge_request, current_user)
.execute
2017-09-10 17:25:29 +05:30
end
2019-09-30 21:07:59 +05:30
def close_merge_request_if_no_source_project
return if @merge_request.source_project
return unless @merge_request.open?
@merge_request.close
end
2017-09-10 17:25:29 +05:30
end
2019-12-04 20:38:33 +05:30
Projects::MergeRequests::ApplicationController.prepend_if_ee('EE::Projects::MergeRequests::ApplicationController')