Class: Projects::MergeRequests::DiffsController

Inherits:
ApplicationController
  • Object
show all
Includes:
DiffHelper, RendersNotes
Defined in:
app/controllers/projects/merge_requests/diffs_controller.rb

Instance Method Summary collapse

Methods included from RendersNotes

#prepare_notes_for_rendering

Methods included from DiffHelper

#apply_diff_view_cookie!, #diff_file_blob_raw_path, #diff_file_blob_raw_url, #diff_file_changed_icon, #diff_file_changed_icon_color, #diff_file_html_data, #diff_file_old_blob_raw_path, #diff_file_old_blob_raw_url, #diff_line_content, #diff_match_line, #diff_options, #diff_view, #diffs_expanded?, #editable_diff?, #inline_diff_btn, #mark_inline_diffs, #parallel_diff_btn, #parallel_diff_discussions, #render_overflow_warning?, #submodule_diff_compare_link, #submodule_link

Instance Method Details

#diff_for_pathObject


18
19
20
# File 'app/controllers/projects/merge_requests/diffs_controller.rb', line 18

def diff_for_path
  render_diffs
end

#diffs_batchObject


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/projects/merge_requests/diffs_controller.rb', line 22

def diffs_batch
  diffs = @compare.diffs_in_batch(params[:page], params[:per_page], diff_options: diff_options)
  positions = @merge_request.note_positions_for_paths(diffs.diff_file_paths, current_user)
  environment = @merge_request.environments_for(current_user, latest: true).last

  diffs.unfold_diff_files(positions.unfoldable)
  diffs.write_cache

  options = {
    environment: environment,
    merge_request: @merge_request,
    diff_view: diff_view,
    pagination_data: diffs.pagination_data
  }

  render json: PaginatedDiffSerializer.new(current_user: current_user).represent(diffs, options)
end

#diffs_metadataObject


40
41
42
43
44
45
# File 'app/controllers/projects/merge_requests/diffs_controller.rb', line 40

def 
  diffs = @compare.diffs(diff_options)

  render json: DiffsMetadataSerializer.new(project: @merge_request.project, current_user: current_user)
                 .represent(diffs, additional_attributes)
end

#showObject


14
15
16
# File 'app/controllers/projects/merge_requests/diffs_controller.rb', line 14

def show
  render_diffs
end