Class: GitJump::Actions::Add
Overview
Action to manually add a branch to tracking
Instance Attribute Summary collapse
-
#branch_name ⇒ Object
readonly
Returns the value of attribute branch_name.
-
#verify ⇒ Object
readonly
Returns the value of attribute verify.
Attributes inherited from Base
#config, #database, #output, #repository
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(branch_name:, verify: true) ⇒ Add
constructor
A new instance of Add.
Constructor Details
#initialize(branch_name:, verify: true) ⇒ Add
Returns a new instance of Add.
11 12 13 14 15 |
# File 'lib/git_jump/actions/add.rb', line 11 def initialize(branch_name:, verify: true, **) super(**) @branch_name = branch_name @verify = verify end |
Instance Attribute Details
#branch_name ⇒ Object (readonly)
Returns the value of attribute branch_name.
9 10 11 |
# File 'lib/git_jump/actions/add.rb', line 9 def branch_name @branch_name end |
#verify ⇒ Object (readonly)
Returns the value of attribute verify.
9 10 11 |
# File 'lib/git_jump/actions/add.rb', line 9 def verify @verify end |
Instance Method Details
#execute ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/git_jump/actions/add.rb', line 17 def execute if verify && !repository.branch_exists?(branch_name) output.error("Branch '#{branch_name}' does not exist in repository") return false end database.add_branch(project_id, branch_name) output.success("Added branch '#{branch_name}' to tracking for #{repository.project_basename}") # Check if we've exceeded max_branches total = database.count_branches(project_id) max = config.max_branches output.warning("Project has #{total} branches (max: #{max}). Consider running 'git-jump clear'") if total > max true end |