Class: Ace::Git::Worktree::Commands::CleanupCommand
- Inherits:
-
Object
- Object
- Ace::Git::Worktree::Commands::CleanupCommand
- Defined in:
- lib/ace/git/worktree/commands/cleanup_command.rb
Overview
Cleanup command
Generates a complete, deterministic, report-only worktree cleanup inventory using ancestry as the first safe proof. No mutations are performed — this is strictly a report.
Instance Method Summary collapse
-
#run(args = []) ⇒ Integer
Run the cleanup command.
-
#show_help ⇒ Integer
Show help.
Instance Method Details
#run(args = []) ⇒ Integer
Run the cleanup command
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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/ace/git/worktree/commands/cleanup_command.rb', line 27 def run(args = []) = parse_arguments(args) return show_help if [:help] () reporter = Molecules::CleanupReporter.new( target: [:target], remote: [:remote], offline: [:offline] ) result = reporter.report if result[:success] if [:apply] applier = Molecules::CleanupApplier.new(result, [:approved_digest]) apply_result = applier.apply if apply_result[:success] # Strict rescan final_reporter = Molecules::CleanupReporter.new( target: [:target], remote: [:remote], offline: [:offline] ) final_result = final_reporter.report if final_result[:success] # Check require_only_target if needed if [:require_only_target] && has_non_target_state?(final_result) puts "Cleanup applied successfully, but non-target state remains (failed strict --require-only-target check)." display_result(final_result, ) return 1 end display_apply_result(apply_result, final_result, ) return 0 else puts "Cleanup applied successfully, but final strict rescan failed: #{final_result[:error]}" return 1 end else puts "Error applying cleanup: #{apply_result[:error]}" display_apply_result(apply_result, nil, ) return 1 end else display_result(result, ) return 0 end else if [:format] == "json" puts JSON.pretty_generate(result) else puts "Error: #{result[:error]}" end 1 end rescue ArgumentError => e puts "Error: #{e.}" puts show_help 1 rescue => e puts "Error: #{e.}" 1 end |
#show_help ⇒ Integer
Show help
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/ace/git/worktree/commands/cleanup_command.rb', line 99 def show_help puts <<~HELP USAGE ace-git-worktree cleanup --target <ref> --remote <name> [OPTIONS] OPTIONS --target <ref> Target ref for ancestry proof (required) --remote <name> Remote name (default: origin) --offline Skip remote evidence refresh --apply Apply a reviewed plan --approved-digest <sha256> Approved plan digest to apply --require-only-target Fail if final rescan has retained non-target state --format <type> Output format: table, json (default: table) --help Show this help DESCRIPTION Generates a complete cleanup inventory without performing any mutations. Each worktree, local ref, and remote ref is classified by ancestry proof and retention policy. The report includes a canonical SHA-256 plan digest that can be used with --apply (in a future version) to safely execute the reviewed plan. EXAMPLES ace-git-worktree cleanup --target main ace-git-worktree cleanup --target main --format json ace-git-worktree cleanup --target main --offline HELP 0 end |