Class: Henitai::DirtySourceDetector

Inherits:
Object
  • Object
show all
Defined in:
lib/henitai/dirty_source_detector.rb

Overview

Answers whether any configured source root has changed, which is what makes a prior run's survivor verdicts unsafe to reuse.

Two change sets are considered together: files dirty in the worktree, and files committed since the run being reused. Test-only churn is deliberately ignored — a spec edit invalidates nothing about a mutant, only about whether it is still killed, which the survivor rerun is about to re-measure anyway.

Every failure mode answers true. A wrong true costs one extra rerun; a wrong false silently reuses a stale verdict, which is the whole failure this guard exists to prevent.

Instance Method Summary collapse

Constructor Details

#initialize(includes:, git_diff_analyzer:) ⇒ DirtySourceDetector

Returns a new instance of DirtySourceDetector.



17
18
19
20
# File 'lib/henitai/dirty_source_detector.rb', line 17

def initialize(includes:, git_diff_analyzer:)
  @includes = includes
  @git_diff_analyzer = git_diff_analyzer
end

Instance Method Details

#dirty?(dirty_worktree_files, git_sha: nil) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
25
26
27
28
29
30
31
# File 'lib/henitai/dirty_source_detector.rb', line 22

def dirty?(dirty_worktree_files, git_sha: nil)
  # A nil list means the worktree could not be read at all, not that it is
  # clean.
  return true if dirty_worktree_files.nil?

  all_changed = dirty_worktree_files + committed_changed_files(git_sha)
  all_changed.any? { |path| in_include_root?(normalize_path(path)) }
rescue StandardError
  true
end