class Gitx::Cli::UpdateCommand

Public Instance Methods

update() click to toggle source
# File lib/gitx/cli/update_command.rb, line 9
def update
  say 'Updating '
  say "#{current_branch.name} ", :green
  say 'with latest changes from '
  say config.base_branch, :green

  update_base_branch
  update_branch(current_branch.name) if remote_branch_exists?(current_branch.name)
  update_branch(config.base_branch, repository: '.')

  run_git_cmd 'share'
end

Private Instance Methods

remote_branch_exists?(branch) click to toggle source
# File lib/gitx/cli/update_command.rb, line 37
def remote_branch_exists?(branch)
  repo.branches.each_name(:remote).include?("origin/#{branch}")
end
update_base_branch() click to toggle source
# File lib/gitx/cli/update_command.rb, line 24
def update_base_branch
  branch_name = current_branch.name
  checkout_branch(config.base_branch)
  update_branch(config.base_branch)
  checkout_branch(branch_name)
end
update_branch(branch, repository: 'origin') click to toggle source
# File lib/gitx/cli/update_command.rb, line 31
def update_branch(branch, repository: 'origin')
  run_git_cmd 'pull', repository, branch
rescue Gitx::Executor::ExecutionError
  raise MergeError, 'Merge conflict occurred. Please fix merge conflict and rerun the command'
end