Class: Ace::Git::Worktree::Commands::PruneCommand
- Inherits:
-
Object
- Object
- Ace::Git::Worktree::Commands::PruneCommand
- Defined in:
- lib/ace/git/worktree/commands/prune_command.rb
Overview
Prune command
Cleans up git metadata for deleted worktrees and removes orphaned worktree directories that are no longer tracked by git.
Instance Method Summary collapse
-
#initialize ⇒ PruneCommand
constructor
Initialize a new PruneCommand.
-
#run(args = []) ⇒ Integer
Run the prune command.
-
#show_help ⇒ Integer
Show help for the prune command.
Constructor Details
#initialize ⇒ PruneCommand
Initialize a new PruneCommand
19 20 21 |
# File 'lib/ace/git/worktree/commands/prune_command.rb', line 19 def initialize @manager = Organisms::WorktreeManager.new end |
Instance Method Details
#run(args = []) ⇒ Integer
Run the prune 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 |
# File 'lib/ace/git/worktree/commands/prune_command.rb', line 27 def run(args = []) = parse_arguments(args) return show_help if [:help] () result = @manager.prune if result[:success] display_prune_result(result, ) # Additional directory cleanup if requested if [:cleanup_directories] cleanup_orphaned_directories() end 0 else puts "Failed to prune worktrees: #{result[:error]}" 1 end rescue ArgumentError => e puts "Error: #{e.}" puts show_help 1 rescue => e puts "Error: #{e.}" 1 end |
#show_help ⇒ Integer
Show help for the prune command
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 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/ace/git/worktree/commands/prune_command.rb', line 61 def show_help puts <<~HELP ace-git-worktree prune - Clean up deleted worktrees USAGE: ace-git-worktree prune [OPTIONS] OPTIONS: --dry-run Show what would be pruned without pruning --cleanup-directories Remove orphaned worktree directories --verbose, -v Show detailed pruning information --help, -h Show this help message EXAMPLES: # Prune deleted worktrees (git metadata cleanup only) ace-git-worktree prune # Dry run to see what would be pruned ace-git-worktree prune --dry-run # Prune and cleanup orphaned directories ace-git-worktree prune --cleanup-directories # Verbose output ace-git-worktree prune --verbose WHAT IT DOES: 1. Prunes git worktree metadata for deleted worktrees 2. Removes stale worktree entries from git's tracking 3. Optionally removes orphaned worktree directories 4. Reports what was cleaned up SAFETY: • Only removes worktrees that are no longer tracked by git • Does not affect active worktrees or current worktree • Directory cleanup is optional and requires explicit flag • Dry run available to preview changes CONFIGURATION: Pruning behavior can be configured in .ace/git/worktree.yml: - cleanup.on_delete: Automatic cleanup on branch deletion - cleanup.on_merge: Automatic cleanup on branch merge HELP 0 end |