Module: Datadog::CI::SourceCode::PathFilter

Defined in:
lib/datadog/ci/source_code/path_filter.rb

Overview

PathFilter determines whether a file path should be included in test impact analysis.

A path is included if:

  • It starts with root_path (prefix match)

  • It does NOT start with ignored_path (when ignored_path is set)

This module mirrors the C implementation in datadog_common.c (dd_ci_is_path_included).

Class Method Summary collapse

Class Method Details

.included?(path, root_path, ignored_path = nil) ⇒ Boolean

Check if a file path should be included in analysis.

Parameters:

  • The file path to check

  • The root path prefix (required)

  • (defaults to: nil)

    Path prefix to exclude (optional)

Returns:

  • true if the path should be included



20
21
22
23
24
25
26
27
28
29
# File 'lib/datadog/ci/source_code/path_filter.rb', line 20

def self.included?(path, root_path, ignored_path = nil)
  return false unless path.is_a?(String) && root_path.is_a?(String)
  return false unless path.start_with?(root_path)

  if ignored_path.is_a?(String) && !ignored_path.empty?
    return false if path.start_with?(ignored_path)
  end

  true
end