Class: Projects::MergeRequests::CreationsController

Inherits:
ApplicationController
  • Object
show all
Includes:
DiffForPath, DiffHelper, RendersCommits
Defined in:
app/controllers/projects/merge_requests/creations_controller.rb

Instance Method Summary collapse

Methods included from RendersCommits

#limited_commits, #prepare_commits_for_rendering, #set_commits_for_rendering, #valid_ref?

Methods included from DiffHelper

#apply_diff_view_cookie!, #collapsed_diff_url, #conflicts, #diff_file_blob_raw_path, #diff_file_blob_raw_url, #diff_file_html_data, #diff_file_old_blob_raw_path, #diff_file_old_blob_raw_url, #diff_file_stats_data, #diff_line_content, #diff_link_number, #diff_match_line, #diff_nomappinginraw_line, #diff_options, #diff_view, #diffs_expanded?, #editable_diff?, #inline_diff_btn, #mark_inline_diffs, #parallel_diff_btn, #parallel_diff_discussions, #render_fork_suggestion, #render_overflow_warning?, #show_only_context_commits?, #submodule_diff_compare_link, #submodule_link

Methods included from DiffForPath

#render_diff_for_path

Instance Method Details

#branch_fromObject


69
70
71
72
73
74
75
76
77
78
79
# File 'app/controllers/projects/merge_requests/creations_controller.rb', line 69

def branch_from
  # This is always source
  @source_project = @merge_request.nil? ? @project : @merge_request.source_project

  if params[:ref].present?
    @ref = params[:ref]
    @commit = @repository.commit(Gitlab::Git::BRANCH_REF_PREFIX + @ref)
  end

  render layout: false
end

#branch_toObject


81
82
83
84
85
86
87
88
89
90
# File 'app/controllers/projects/merge_requests/creations_controller.rb', line 81

def branch_to
  @target_project = selected_target_project

  if @target_project && params[:ref].present? && Ability.allowed?(current_user, :create_merge_request_in, @target_project)
    @ref = params[:ref]
    @commit = @target_project.commit(Gitlab::Git::BRANCH_REF_PREFIX + @ref)
  end

  render layout: false
end

#createObject


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/projects/merge_requests/creations_controller.rb', line 26

def create
  @merge_request = ::MergeRequests::CreateService.new(project: project, current_user: current_user, params: merge_request_params).execute

  if @merge_request.valid?
    incr_count_webide_merge_request

    redirect_to(merge_request_path(@merge_request))
  else
    @source_project = @merge_request.source_project
    @target_project = @merge_request.target_project

    define_new_vars
    render action: "new"
  end
end

#diff_for_pathObject


62
63
64
65
66
67
# File 'app/controllers/projects/merge_requests/creations_controller.rb', line 62

def diff_for_path
  @diffs = @merge_request.diffs(diff_options)
  @diff_notes_disabled = true

  render_diff_for_path(@diffs)
end

#diffsObject


54
55
56
57
58
59
60
# File 'app/controllers/projects/merge_requests/creations_controller.rb', line 54

def diffs
  @diffs = @merge_request.diffs(diff_options) if @merge_request.can_be_created

  @diff_notes_disabled = true

  render json: { html: view_to_html_string('projects/merge_requests/creations/_diffs', diffs: @diffs) }
end

#newObject


22
23
24
# File 'app/controllers/projects/merge_requests/creations_controller.rb', line 22

def new
  define_new_vars
end

#pipelinesObject


42
43
44
45
46
47
48
49
50
51
52
# File 'app/controllers/projects/merge_requests/creations_controller.rb', line 42

def pipelines
  @pipelines = Ci::PipelinesForMergeRequestFinder.new(@merge_request, current_user).execute

  Gitlab::PollingInterval.set_header(response, interval: 10_000)

  render json: {
    pipelines: PipelineSerializer
    .new(project: @project, current_user: current_user)
    .represent(@pipelines)
  }
end