Class: Gitlab::Diff::FileCollection::MergeRequestDiffBase
- Extended by:
- Utils::Override
- Defined in:
- lib/gitlab/diff/file_collection/merge_request_diff_base.rb
Direct Known Subclasses
MergeRequestDiff, MergeRequestDiffBatch, PaginatedMergeRequestDiff
Constant Summary collapse
- MAX_BLOB_SIZE =
This is the minimum ‘max blob size’ we request for each of the diff files We use the blobs for checking encoding type and LFS pointer gitlab.com/gitlab-org/gitlab/-/blob/ab046ed8500fb691450d565710cad9f7a5257218/lib/gitlab/git/blob.rb#L10
512.kilobytes
Instance Attribute Summary
Attributes inherited from Base
#diff_options, #diff_refs, #diffable, #fallback_diff_refs, #project
Class Method Summary collapse
Instance Method Summary collapse
- #clear_cache ⇒ Object
- #diff_files(sorted: false) ⇒ Object
-
#initialize(merge_request_diff, diff_options:) ⇒ MergeRequestDiffBase
constructor
A new instance of MergeRequestDiffBase.
- #raw_diff_files(sorted: false) ⇒ Object
- #write_cache ⇒ Object
Methods included from Utils::Override
extended, extensions, included, method_added, override, prepended, queue_verification, verify!
Methods inherited from Base
default_options, #diff_file_paths, #diff_file_with_new_path, #diff_file_with_old_path, #diff_paths, #diffs, #overflow?, #pagination_data, #unfold_diff_files
Constructor Details
#initialize(merge_request_diff, diff_options:) ⇒ MergeRequestDiffBase
Returns a new instance of MergeRequestDiffBase.
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/gitlab/diff/file_collection/merge_request_diff_base.rb', line 16 def initialize(merge_request_diff, diff_options:) @merge_request_diff = merge_request_diff super(merge_request_diff, project: merge_request_diff.project, diff_options: , diff_refs: merge_request_diff.diff_refs, fallback_diff_refs: merge_request_diff.fallback_diff_refs ) end |
Class Method Details
.max_blob_size(project) ⇒ Object
58 59 60 61 62 63 |
# File 'lib/gitlab/diff/file_collection/merge_request_diff_base.rb', line 58 def self.max_blob_size(project) # We take into account for the highlight limit to avoid an extra gitaly call # When the real blob size is between the highlight limit and the max blob size # https://gitlab.com/gitlab-org/gitlab/-/merge_requests/152151#note_1904271976 [MAX_BLOB_SIZE, Gitlab::Highlight.file_size_limit].max end |
Instance Method Details
#clear_cache ⇒ Object
52 53 54 55 |
# File 'lib/gitlab/diff/file_collection/merge_request_diff_base.rb', line 52 def clear_cache highlight_cache.clear diff_stats_cache.clear end |
#diff_files(sorted: false) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/gitlab/diff/file_collection/merge_request_diff_base.rb', line 27 def diff_files(sorted: false) strong_memoize(:diff_files) do diff_files = super Gitlab::Metrics.measure(:diffs_highlight_cache_decorate) do diff_files.each { |diff_file| highlight_cache.decorate(diff_file) } end diff_files end end |
#raw_diff_files(sorted: false) ⇒ Object
39 40 41 42 43 |
# File 'lib/gitlab/diff/file_collection/merge_request_diff_base.rb', line 39 def raw_diff_files(sorted: false) # We force `sorted` to `false` as we don't need to sort the diffs when # dealing with `MergeRequestDiff` since we sort its files on create. super(sorted: false) end |
#write_cache ⇒ Object
46 47 48 49 |
# File 'lib/gitlab/diff/file_collection/merge_request_diff_base.rb', line 46 def write_cache highlight_cache.write_if_empty diff_stats_cache.write_if_empty(diff_stats_collection) end |