class Thegarage::Gitx::Cli::UpdateCommand
Public Instance Methods
update()
click to toggle source
# File lib/thegarage/gitx/cli/update_command.rb, line 10 def update say "Updating " say "#{current_branch.name} ", :green say "with latest changes from " say Thegarage::Gitx::BASE_BRANCH, :green update_branch(current_branch.name) if remote_branch_exists?(current_branch.name) update_branch(Thegarage::Gitx::BASE_BRANCH) run_cmd 'git push origin HEAD' end
Private Instance Methods
remote_branch_exists?(branch)
click to toggle source
# File lib/thegarage/gitx/cli/update_command.rb, line 31 def remote_branch_exists?(branch) repo.branches.each_name(:remote).include?("origin/#{branch}") end
update_branch(branch)
click to toggle source
# File lib/thegarage/gitx/cli/update_command.rb, line 23 def update_branch(branch) begin run_cmd "git pull origin #{branch}" rescue fail MergeError, "Merge Conflict Occurred. Please fix merge conflict and rerun the update command" end end