Commit 317e4819 authored by Adam Niedzielski's avatar Adam Niedzielski

Fix the diff in the merge request view when converting a symlink to a regular file.

In this specific case using file_path as a cache key is not enough,
because there are two entries with the same path.
Closes #21610.
parent d4feb781
......@@ -103,6 +103,7 @@ Please view this file on the master branch, on stable branches it's out of date.
- Reduce queries needed to find users using their SSH keys when pushing commits
- Prevent rendering the link to all when the author has no access (Katarzyna Kobierska Ula Budziszewska)
- Fix broken repository 500 errors in project list
- Fix the diff in the merge request view when converting a symlink to a regular file
- Fix Pipeline list commit column width should be adjusted
- Close todos when accepting merge requests via the API !6486 (tonygambone)
- Ability to batch assign issues relating to a merge request to the author. !5725 (jamedjo)
......
......@@ -125,6 +125,10 @@ module Gitlab
repository.blob_at(commit.id, file_path)
end
def cache_key
"#{file_path}-#{new_file}-#{deleted_file}-#{renamed_file}"
end
end
end
end
......@@ -35,16 +35,16 @@ module Gitlab
# for the highlighted ones, so we just skip their execution.
# If the highlighted diff files lines are not cached we calculate and cache them.
#
# The content of the cache is a Hash where the key correspond to the file_path and the values are Arrays of
# The content of the cache is a Hash where the key identifies the file and the values are Arrays of
# hashes that represent serialized diff lines.
#
def cache_highlight!(diff_file)
file_path = diff_file.file_path
item_key = diff_file.cache_key
if highlight_cache[file_path]
highlight_diff_file_from_cache!(diff_file, highlight_cache[file_path])
if highlight_cache[item_key]
highlight_diff_file_from_cache!(diff_file, highlight_cache[item_key])
else
highlight_cache[file_path] = diff_file.highlighted_diff_lines.map(&:to_hash)
highlight_cache[item_key] = diff_file.highlighted_diff_lines.map(&:to_hash)
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