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
|
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2017-09-10 17:25:29 +05:30
|
|
|
def merge_request
|
2018-11-18 11:00:15 +05:30
|
|
|
@issuable = @merge_request ||= @project.merge_requests.includes(author: :status).find_by!(iid: params[:id])
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
2018-12-05 23:21:45 +05:30
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
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
|
|
|
:assignee_id,
|
|
|
|
: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,
|
2017-09-10 17:25:29 +05:30
|
|
|
label_ids: []
|
|
|
|
]
|
|
|
|
end
|
|
|
|
|
|
|
|
def set_pipeline_variables
|
2019-02-13 22:33:31 +05:30
|
|
|
@pipelines =
|
|
|
|
if can?(current_user, :read_pipeline, @project)
|
|
|
|
@merge_request.all_pipelines
|
|
|
|
else
|
|
|
|
Ci::Pipeline.none
|
|
|
|
end
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
end
|