Class: Mj::Git::Commands::DeleteStaleBranchesCommandHandler
- Inherits:
-
Object
- Object
- Mj::Git::Commands::DeleteStaleBranchesCommandHandler
- Defined in:
- lib/mj/git/commands/delete_stale_branches_command_handler.rb
Instance Method Summary collapse
- #handle(command) ⇒ Object
-
#initialize(stdout:, command_executer: CommandExecuter.new) ⇒ DeleteStaleBranchesCommandHandler
constructor
A new instance of DeleteStaleBranchesCommandHandler.
Constructor Details
#initialize(stdout:, command_executer: CommandExecuter.new) ⇒ DeleteStaleBranchesCommandHandler
Returns a new instance of DeleteStaleBranchesCommandHandler.
7 8 9 10 |
# File 'lib/mj/git/commands/delete_stale_branches_command_handler.rb', line 7 def initialize(stdout:, command_executer: CommandExecuter.new) @stdout = stdout @command_executer = command_executer end |
Instance Method Details
#handle(command) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/mj/git/commands/delete_stale_branches_command_handler.rb', line 12 def handle(command) puts("Deleting stale branches", color: :blue) list_command = "git branch -a" list_command += " | grep remotes/ | grep -v '/HEAD'" branches = Git::Branches .from_branch_names(@command_executer.execute(list_command)) .sort_by(&:last_commit_date) branches.each do |branch| delete_branch(branch, command: command) end end |