Commit c9d7ba4d authored by Sean McGivern's avatar Sean McGivern

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

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

## What does this MR do?

It fixes a bug described in #21610

## Why was this MR needed?

There was a regression introduced in https://gitlab.com/gitlab-org/gitlab-ce/commit/cd7c2cb6ddd4d9c9f9bdae00c887c0022c121c17

## Does this MR meet the acceptance criteria?

- [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- Tests
  - [x] All builds are passing
- [x] Conform by the [merge request performance guides](http://docs.gitlab.com/ce/development/merge_request_performance_guidelines.html)
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] Branch has no merge conflicts with `master` (if it does - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

## What are the relevant issue numbers?

Fixes #21610

See merge request !6828
parents b1be3220 317e4819
...@@ -106,6 +106,7 @@ Please view this file on the master branch, on stable branches it's out of date. ...@@ -106,6 +106,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 - 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) - 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 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 - Fix Pipeline list commit column width should be adjusted
- Close todos when accepting merge requests via the API !6486 (tonygambone) - 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) - Ability to batch assign issues relating to a merge request to the author. !5725 (jamedjo)
......
...@@ -125,6 +125,10 @@ module Gitlab ...@@ -125,6 +125,10 @@ module Gitlab
repository.blob_at(commit.id, file_path) repository.blob_at(commit.id, file_path)
end end
def cache_key
"#{file_path}-#{new_file}-#{deleted_file}-#{renamed_file}"
end
end end
end end
end end
...@@ -35,16 +35,16 @@ module Gitlab ...@@ -35,16 +35,16 @@ module Gitlab
# for the highlighted ones, so we just skip their execution. # for the highlighted ones, so we just skip their execution.
# If the highlighted diff files lines are not cached we calculate and cache them. # 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. # hashes that represent serialized diff lines.
# #
def cache_highlight!(diff_file) def cache_highlight!(diff_file)
file_path = diff_file.file_path item_key = diff_file.cache_key
if highlight_cache[file_path] if highlight_cache[item_key]
highlight_diff_file_from_cache!(diff_file, highlight_cache[file_path]) highlight_diff_file_from_cache!(diff_file, highlight_cache[item_key])
else 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
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