class Thegarage::Gitx::Cli::BaseCommand
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
# File lib/thegarage/gitx/cli/base_command.rb, line 17 def initialize(*args) super(*args) end
Private Instance Methods
assert_aggregate_branch!(target_branch)
click to toggle source
# File lib/thegarage/gitx/cli/base_command.rb, line 39 def assert_aggregate_branch!(target_branch) fail "Invalid aggregate branch: #{target_branch} must be one of supported aggregate branches #{config.aggregate_branches}" unless config.aggregate_branch?(target_branch) end
assert_not_protected_branch!(branch, action)
click to toggle source
# File lib/thegarage/gitx/cli/base_command.rb, line 43 def assert_not_protected_branch!(branch, action) raise "Cannot #{action} reserved branch" if config.reserved_branch?(branch) || config.aggregate_branch?(branch) end
checkout_branch(branch_name)
click to toggle source
# File lib/thegarage/gitx/cli/base_command.rb, line 30 def checkout_branch(branch_name) run_cmd "git checkout #{branch_name}" end
config()
click to toggle source
# File lib/thegarage/gitx/cli/base_command.rb, line 52 def config @configuration ||= Thegarage::Gitx::Configuration.new(repo.workdir) end
current_branch()
click to toggle source
lookup the current branch of the repo
# File lib/thegarage/gitx/cli/base_command.rb, line 35 def current_branch repo.branches.find(&:head?) end
execute_command(command_class, method, args = [])
click to toggle source
helper to invoke other CLI commands
# File lib/thegarage/gitx/cli/base_command.rb, line 48 def execute_command(command_class, method, args = []) command_class.new.send(method, *args) end
repo()
click to toggle source
# File lib/thegarage/gitx/cli/base_command.rb, line 23 def repo @repo ||= begin path = Dir.pwd Rugged::Repository.discover(path) end end