class Selective::Ruby::Core::FileCorrelator

def correlate

def correlate
  JSON.parse(get_correlated_files, symbolize_names: true)
rescue FileCorrelatorError, JSON::ParserError
  print_warning(<<~MSG)
    Selective was unable to correlate the diff to test files. This may result in a sub-optimal test order.
    If the issue persists, please contact support.
  MSG
end

def get_correlated_files

def get_correlated_files
  Open3.capture2e("#{FILE_CORRELATION_COLLECTOR_PATH} #{target_branch} #{num_commits} #{diff.join(" ")}").then do |output, status|
    raise FileCorrelatorError unless status.success?
    output
  end
end

def initialize(diff, num_commits, target_branch)

def initialize(diff, num_commits, target_branch)
  @diff = diff.reject {|f| f =~ /^spec\// }
  @num_commits = num_commits
  @target_branch = target_branch
end