Class: Ace::Overseer::Molecules::PruneSafetyChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/ace/overseer/molecules/prune_safety_checker.rb

Instance Method Summary collapse

Constructor Details

#initialize(context_collector: nil, task_loader_factory: nil) ⇒ PruneSafetyChecker

Returns a new instance of PruneSafetyChecker.



9
10
11
12
# File 'lib/ace/overseer/molecules/prune_safety_checker.rb', line 9

def initialize(context_collector: nil, task_loader_factory: nil)
  @context_collector = context_collector || WorktreeContextCollector.new
  @task_loader_factory = task_loader_factory || -> { Ace::Task::Organisms::TaskManager.new }
end

Instance Method Details

#check(worktree_path:, task_ref:) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/ace/overseer/molecules/prune_safety_checker.rb', line 14

def check(worktree_path:, task_ref:)
  context = @context_collector.collect(worktree_path)

  assignment_complete = assignment_complete?(context.assignment_status)
  task_done = task_done?(worktree_path, task_ref)
  git_clean = git_clean_for_prune?(worktree_path, context.git_status)

  reasons = []
  reasons << "assignment not complete" unless assignment_complete
  reasons << "task not done" unless task_done
  reasons << "git not clean" unless git_clean

  Models::PruneCandidate.new(
    task_id: task_ref,
    worktree_path: worktree_path,
    assignment_complete: assignment_complete,
    task_done: task_done,
    git_clean: git_clean,
    reasons: reasons
  )
end