diff options
author | Sean McGivern <sean@gitlab.com> | 2016-07-08 22:50:06 +0100 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2016-07-11 09:31:34 +0100 |
commit | 5266ae87c43a6760600e397257f9791d950dbe15 (patch) | |
tree | 83e840670b4c772020be590e5934586fe746df6e /app | |
parent | e462e122784f40550c53224af5a58b201ed1fd8f (diff) | |
download | gitlab-ce-5266ae87c43a6760600e397257f9791d950dbe15.tar.gz |
Support renames in diff_for_path actions
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/diff_helper.rb | 8 | ||||
-rw-r--r-- | app/models/merge_request_diff.rb | 5 | ||||
-rw-r--r-- | app/views/projects/diffs/_content.html.haml | 2 |
3 files changed, 10 insertions, 5 deletions
diff --git a/app/helpers/diff_helper.rb b/app/helpers/diff_helper.rb index 04490226e50..e29f665baec 100644 --- a/app/helpers/diff_helper.rb +++ b/app/helpers/diff_helper.rb @@ -24,7 +24,11 @@ module DiffHelper def diff_options default_options = Commit.max_diff_options - default_options[:paths] = [params[:path]] if params[:path] + + if action_name == 'diff_for_path' + default_options[:paths] = params.values_at(:old_path, :new_path) + end + default_options.merge(ignore_whitespace_change: hide_whitespace?) end @@ -88,7 +92,7 @@ module DiffHelper def commit_for_diff(diff_file) return diff_file.content_commit if diff_file.content_commit - + if diff_file.deleted_file @base_commit || @commit.parent || @commit else diff --git a/app/models/merge_request_diff.rb b/app/models/merge_request_diff.rb index 7e22491d0a3..d54369c3483 100644 --- a/app/models/merge_request_diff.rb +++ b/app/models/merge_request_diff.rb @@ -47,7 +47,7 @@ class MergeRequestDiff < ActiveRecord::Base end else @diffs ||= {} - @diffs[options[:paths]] ||= load_diffs(st_diffs, options) + @diffs[options] ||= load_diffs(st_diffs, options) end end @@ -146,8 +146,9 @@ class MergeRequestDiff < ActiveRecord::Base def load_diffs(raw, options) if raw.respond_to?(:each) if options[:paths] + old_path, new_path = options[:paths] raw = raw.select do |diff| - options[:paths].include?(diff[:new_path]) + old_path == diff[:old_path] && new_path == diff[:new_path] end end diff --git a/app/views/projects/diffs/_content.html.haml b/app/views/projects/diffs/_content.html.haml index bfcd3ee9132..0c0424edffd 100644 --- a/app/views/projects/diffs/_content.html.haml +++ b/app/views/projects/diffs/_content.html.haml @@ -10,7 +10,7 @@ .nothing-here-block This diff was suppressed by a .gitattributes entry. - elsif diff_file.diff_lines.length > 0 - if diff_file.collapsed_by_default? && !expand_all_diffs? - - url = url_for(params.merge(action: :diff_for_path, path: diff_file.file_path, format: nil)) + - url = url_for(params.merge(action: :diff_for_path, old_path: diff_file.old_path, new_path: diff_file.new_path)) .nothing-here-block.diff-collapsed{data: { diff_for_path: url } } This diff is collapsed. Click to expand it. - elsif diff_view == 'parallel' |