BigW Consortium Gitlab

diff_for_path.rb 572 Bytes
Newer Older
1 2 3
module DiffForPath
  extend ActiveSupport::Concern

4 5
  def render_diff_for_path(diffs)
    diff_file = diffs.diff_files.find do |diff|
6
      diff.file_identifier == params[:file_identifier]
7
    end
8 9 10 11 12 13 14 15 16

    return render_404 unless diff_file

    diff_commit = commit_for_diff(diff_file)
    blob = diff_file.blob(diff_commit)

    locals = {
      diff_file: diff_file,
      diff_commit: diff_commit,
17
      diff_refs: diffs.diff_refs,
18 19 20 21 22 23 24
      blob: blob,
      project: project
    }

    render json: { html: view_to_html_string('projects/diffs/_content', locals) }
  end
end