Class: Gitx::Cli::CleanupCommand

Inherits:
BaseCommand show all
Defined in:
lib/gitx/cli/cleanup_command.rb

Instance Method Summary collapse

Methods inherited from BaseCommand

#initialize

Methods included from Thor::Actions

#ask_editor, #run_cmd

Constructor Details

This class inherits a constructor from Gitx::Cli::BaseCommand

Instance Method Details

#cleanupObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/gitx/cli/cleanup_command.rb', line 9

def cleanup
  checkout_branch Gitx::BASE_BRANCH
  run_cmd 'git pull'
  run_cmd 'git remote prune origin'

  say 'Deleting local and remote branches that have been merged into '
  say Gitx::BASE_BRANCH, :green
  merged_branches(remote: true).each do |branch|
    run_cmd "git push origin --delete #{branch}"
  end
  merged_branches(remote: false).each do |branch|
    run_cmd "git branch -d #{branch}"
  end
end