diff options
Diffstat (limited to 'app/controllers/concerns/diff_for_path.rb')
-rw-r--r-- | app/controllers/concerns/diff_for_path.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/app/controllers/concerns/diff_for_path.rb b/app/controllers/concerns/diff_for_path.rb new file mode 100644 index 00000000000..aeec3009f15 --- /dev/null +++ b/app/controllers/concerns/diff_for_path.rb @@ -0,0 +1,24 @@ +module DiffForPath + extend ActiveSupport::Concern + + def render_diff_for_path(diffs) + diff_file = diffs.diff_files.find do |diff| + 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, + diff_refs: diffs.diff_refs, + blob: blob, + project: project + } + + render json: { html: view_to_html_string('projects/diffs/_content', locals) } + end +end |