BigW Consortium Gitlab

Commit 8ee3c28b by Sean McGivern

Handle more than two paths in MergeRequest#diffs

parent 93ab6860
......@@ -2,7 +2,9 @@ module DiffForPath
extend ActiveSupport::Concern
def render_diff_for_path(diffs, diff_refs, project)
diff_file = safe_diff_files(diffs, diff_refs: diff_refs, repository: project.repository).first
diff_file = safe_diff_files(diffs, diff_refs: diff_refs, repository: project.repository).find do |diff|
diff.old_path == params[:old_path] && diff.new_path == params[:new_path]
end
return render_404 unless diff_file
......
......@@ -145,10 +145,9 @@ class MergeRequestDiff < ActiveRecord::Base
def load_diffs(raw, options)
if raw.respond_to?(:each)
if options[:paths]
old_path, new_path = options[:paths]
if paths = options[:paths]
raw = raw.select do |diff|
old_path == diff[:old_path] && new_path == diff[:new_path]
paths.include?(diff[:old_path]) || paths.include?(diff[:new_path])
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment