Class: GitJump::Actions::Clear
- Defined in:
- lib/git_jump/actions/clear.rb
Overview
Action to clear branches matching keep patterns
Instance Attribute Summary
Attributes inherited from Base
#config, #database, #output, #repository
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from GitJump::Actions::Base
Instance Method Details
#execute ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/git_jump/actions/clear.rb', line 9 def execute branches = database.list_branches(project_id) if branches.empty? output.info("No branches tracked for #{repository.project_basename}") return true end keep_patterns = config.keep_patterns(repository.project_path) if keep_patterns.empty? output.warning("No keep patterns configured. All branches would be deleted.") output.info("Configure keep_patterns in your config file to use this command") return false end output.info("Keep patterns: #{keep_patterns.join(", ")}") unless output.prompt("Clear branches not matching patterns?") output.info("Cancelled") return false end deleted = database.clear_branches(project_id, keep_patterns) if deleted.zero? output.info("No branches to clear (all match keep patterns)") else output.success("Cleared #{deleted} branch(es)") end true end |