2016-08-24 12:49:21 +05:30
|
|
|
module DiffForPath
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
2016-09-13 17:45:13 +05:30
|
|
|
def render_diff_for_path(diffs)
|
|
|
|
diff_file = diffs.diff_files.find do |diff|
|
2016-08-24 12:49:21 +05:30
|
|
|
diff.old_path == params[:old_path] && diff.new_path == params[:new_path]
|
|
|
|
end
|
|
|
|
|
|
|
|
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-09-13 17:45:13 +05:30
|
|
|
diff_refs: diffs.diff_refs,
|
2016-08-24 12:49:21 +05:30
|
|
|
blob: blob,
|
|
|
|
project: project
|
|
|
|
}
|
|
|
|
|
|
|
|
render json: { html: view_to_html_string('projects/diffs/_content', locals) }
|
|
|
|
end
|
|
|
|
end
|