Class: Gitlab::Checks::DiffCheck

Inherits:
BaseChecker show all
Includes:
Utils::StrongMemoize
Defined in:
lib/gitlab/checks/diff_check.rb

Constant Summary collapse

LOG_MESSAGES =
{
  validate_file_paths: "Validating diffs' file paths...",
  diff_content_check: "Validating diff contents..."
}.freeze

Instance Attribute Summary

Attributes inherited from BaseChecker

#change_access

Instance Method Summary collapse

Methods included from Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Methods inherited from BaseChecker

#initialize

Constructor Details

This class inherits a constructor from Gitlab::Checks::BaseChecker

Instance Method Details

#validate!Object


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/gitlab/checks/diff_check.rb', line 13

def validate!
  return if deletion?
  return unless should_run_diff_validations?
  return if commits.empty?

  file_paths = []

  process_commits do |commit|
    validate_once(commit) do
      commit.raw_deltas.each do |diff|
        file_paths.concat([diff.new_path, diff.old_path].compact)

        validate_diff(diff)
      end
    end
  end

  validate_file_paths(file_paths)
end