class Gitx::Cli::BaseCommand

Private Instance Methods

assert_aggregate_branch!(target_branch) click to toggle source
# File lib/gitx/cli/base_command.rb, line 44
def assert_aggregate_branch!(target_branch)
  raise "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/gitx/cli/base_command.rb, line 48
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/gitx/cli/base_command.rb, line 35
def checkout_branch(branch_name)
  run_git_cmd 'checkout', branch_name
end
config() click to toggle source
# File lib/gitx/cli/base_command.rb, line 52
def config
  @config ||= Gitx::Configuration.new(repo.workdir)
end
current_branch() click to toggle source

lookup the current branch of the repo

# File lib/gitx/cli/base_command.rb, line 40
def current_branch
  repo.branches.find(&:head?)
end
executor() click to toggle source
# File lib/gitx/cli/base_command.rb, line 56
def executor
  @executor ||= Gitx::Executor.new
end
repo() click to toggle source
# File lib/gitx/cli/base_command.rb, line 18
def repo
  @repo ||= begin
    path = Dir.pwd
    Rugged::Repository.discover(path)
  end
end
run_cmd(*cmd) click to toggle source
# File lib/gitx/cli/base_command.rb, line 25
def run_cmd(*cmd)
  executor.execute(*cmd) do |output|
    say(output, :yellow)
  end
end
run_git_cmd(*cmd) click to toggle source
# File lib/gitx/cli/base_command.rb, line 31
def run_git_cmd(*cmd)
  run_cmd('git', *cmd)
end