2016-07-06 13:15:27 -04:00
|
|
|
module DiffForPath
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
2016-07-20 12:25:36 -04:00
|
|
|
def render_diff_for_path(diffs)
|
|
|
|
diff_file = diffs.diff_files.find do |diff|
|
2016-11-10 12:24:12 -05:00
|
|
|
diff.file_identifier == params[:file_identifier]
|
2016-07-11 13:17:00 -04:00
|
|
|
end
|
2016-07-06 13:15:27 -04:00
|
|
|
|
|
|
|
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,
|
2016-07-20 12:25:36 -04:00
|
|
|
diff_refs: diffs.diff_refs,
|
2016-07-06 13:15:27 -04:00
|
|
|
blob: blob,
|
|
|
|
project: project
|
|
|
|
}
|
|
|
|
|
|
|
|
render json: { html: view_to_html_string('projects/diffs/_content', locals) }
|
|
|
|
end
|
|
|
|
end
|