Class: Ace::Git::Worktree::Molecules::CleanupApplier
- Inherits:
-
Object
- Object
- Ace::Git::Worktree::Molecules::CleanupApplier
- Defined in:
- lib/ace/git/worktree/molecules/cleanup_applier.rb
Overview
Applies a reviewed worktree cleanup plan with strict drift guards.
Instance Method Summary collapse
-
#apply ⇒ Hash
Execute the cleanup plan.
-
#initialize(report, approved_digest) ⇒ CleanupApplier
constructor
A new instance of CleanupApplier.
Constructor Details
#initialize(report, approved_digest) ⇒ CleanupApplier
Returns a new instance of CleanupApplier.
14 15 16 17 18 |
# File 'lib/ace/git/worktree/molecules/cleanup_applier.rb', line 14 def initialize(report, approved_digest) @report = report @approved_digest = approved_digest @ledger = [] end |
Instance Method Details
#apply ⇒ Hash
Execute the cleanup plan
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/ace/git/worktree/molecules/cleanup_applier.rb', line 22 def apply if @report[:plan_digest] != @approved_digest return error_result("Digest mismatch. The repository state has drifted since approval. Expected: #{@approved_digest}, Got: #{@report[:plan_digest]}. Please review the new report.") end actions = @report[:actions] return success_result if actions.empty? # Fixed order execution: worktrees, local refs, remote refs worktree_actions = actions.select { |a| a[:type] == "remove_worktree" } local_ref_actions = actions.select { |a| a[:type] == "delete_local_ref" } remote_ref_actions = actions.select { |a| a[:type] == "delete_remote_ref" } failed = false worktree_actions.each do |action| next if failed failed = !execute_worktree_removal(action) end local_ref_actions.each do |action| next if failed failed = !execute_local_ref_deletion(action) end remote_ref_actions.each do |action| next if failed failed = !execute_remote_ref_deletion(action) end if failed { success: false, error: "Cleanup partially failed. See ledger for details.", ledger: @ledger, partial_failure: true } else success_result end end |