Commit 0c7c0edf authored by Sean McGivern's avatar Sean McGivern

Merge branch 'adam-fix-collapsed-diff-symlink-file-conversion' into 'master'

Fix the collapsed diff  when converting a symlink to a regular file

#21610 
!6828

See merge request !6953
parents a5c3bfc9 3fa265d1
...@@ -3,7 +3,7 @@ module DiffForPath ...@@ -3,7 +3,7 @@ module DiffForPath
def render_diff_for_path(diffs) def render_diff_for_path(diffs)
diff_file = diffs.diff_files.find do |diff| diff_file = diffs.diff_files.find do |diff|
diff.old_path == params[:old_path] && diff.new_path == params[:new_path] diff.file_identifier == params[:file_identifier]
end end
return render_404 unless diff_file return render_404 unless diff_file
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
- if !project.repository.diffable?(blob) - if !project.repository.diffable?(blob)
.nothing-here-block This diff was suppressed by a .gitattributes entry. .nothing-here-block This diff was suppressed by a .gitattributes entry.
- elsif diff_file.collapsed? - elsif diff_file.collapsed?
- url = url_for(params.merge(action: :diff_for_path, old_path: diff_file.old_path, new_path: diff_file.new_path)) - url = url_for(params.merge(action: :diff_for_path, old_path: diff_file.old_path, new_path: diff_file.new_path, file_identifier: diff_file.file_identifier))
.nothing-here-block.diff-collapsed{data: { diff_for_path: url } } .nothing-here-block.diff-collapsed{data: { diff_for_path: url } }
This diff is collapsed. This diff is collapsed.
%a.click-to-expand %a.click-to-expand
......
---
title: Fix expanding a collapsed diff when converting a symlink to a regular file
merge_request: 6953
author:
...@@ -126,7 +126,7 @@ module Gitlab ...@@ -126,7 +126,7 @@ module Gitlab
repository.blob_at(commit.id, file_path) repository.blob_at(commit.id, file_path)
end end
def cache_key def file_identifier
"#{file_path}-#{new_file}-#{deleted_file}-#{renamed_file}" "#{file_path}-#{new_file}-#{deleted_file}-#{renamed_file}"
end end
end end
......
...@@ -39,7 +39,7 @@ module Gitlab ...@@ -39,7 +39,7 @@ module Gitlab
# hashes that represent serialized diff lines. # hashes that represent serialized diff lines.
# #
def cache_highlight!(diff_file) def cache_highlight!(diff_file)
item_key = diff_file.cache_key item_key = diff_file.file_identifier
if highlight_cache[item_key] if highlight_cache[item_key]
highlight_diff_file_from_cache!(diff_file, highlight_cache[item_key]) highlight_diff_file_from_cache!(diff_file, highlight_cache[item_key])
......
...@@ -182,6 +182,20 @@ feature 'Expand and collapse diffs', js: true, feature: true do ...@@ -182,6 +182,20 @@ feature 'Expand and collapse diffs', js: true, feature: true do
end end
end end
end end
context 'expanding a diff when symlink was converted to a regular file' do
let(:branch) { 'symlink-expand-diff' }
it 'shows the content of the regular file' do
expect(page).to have_content('This diff is collapsed')
expect(page).to have_no_content('No longer a symlink')
find('.click-to-expand').click
wait_for_ajax
expect(page).to have_content('No longer a symlink')
end
end
end end
context 'visiting a commit without collapsed diffs' do context 'visiting a commit without collapsed diffs' do
......
...@@ -23,6 +23,7 @@ module TestEnv ...@@ -23,6 +23,7 @@ module TestEnv
'binary-encoding' => '7b1cf43', 'binary-encoding' => '7b1cf43',
'gitattributes' => '5a62481', 'gitattributes' => '5a62481',
'expand-collapse-diffs' => '4842455', 'expand-collapse-diffs' => '4842455',
'symlink-expand-diff' => '81e6355',
'expand-collapse-files' => '025db92', 'expand-collapse-files' => '025db92',
'expand-collapse-lines' => '238e82d', 'expand-collapse-lines' => '238e82d',
'video' => '8879059', 'video' => '8879059',
......
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