diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-21 18:21:10 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-21 18:21:10 +0300 |
commit | e33f87ac0fabaab468ce4b457996cc0f1b1bb648 (patch) | |
tree | 8bf0de72a9acac014cfdaddab7d463b208294af2 /app/models/merge_request_diff.rb | |
parent | 5baf990db20a75078684702782c24399ef9eb0fa (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/merge_request_diff.rb')
-rw-r--r-- | app/models/merge_request_diff.rb | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/app/models/merge_request_diff.rb b/app/models/merge_request_diff.rb index 9136c6cc5d4..7b15d21c095 100644 --- a/app/models/merge_request_diff.rb +++ b/app/models/merge_request_diff.rb @@ -366,9 +366,22 @@ class MergeRequestDiff < ApplicationRecord end # rubocop: enable CodeReuse/ServiceClass - def modified_paths - strong_memoize(:modified_paths) do - merge_request_diff_files.pluck(:new_path, :old_path).flatten.uniq + def modified_paths(fallback_on_overflow: false) + if fallback_on_overflow && overflow? + # This is an extremely slow means to find the modified paths for a given + # MergeRequestDiff. This should be avoided, except where the limit of + # 1_000 (as of %12.10) entries returned by the default behavior is an + # issue. + strong_memoize(:overflowed_modified_paths) do + project.repository.diff_stats( + base_commit_sha, + head_commit_sha + ).paths + end + else + strong_memoize(:modified_paths) do + merge_request_diff_files.pluck(:new_path, :old_path).flatten.uniq + end end end |