def checkout(number, branch = true)
request = server.get_request_by_number(number)
puts 'Checking out changes to your local repository.'
puts 'To get back to your original state, just run:'
puts
puts ' git checkout master'.pink
puts
remote = local.remote_for_request(request)
git_call "fetch #{remote}"
branch_name = request.head.ref
if branch
if local.branch_exists?(:local, branch_name)
if local.source_branch == branch_name
puts "On branch #{branch_name}."
else
git_call "checkout #{branch_name}"
end
else
git_call "checkout --track -b #{branch_name} #{remote}/#{branch_name}"
end
else
git_call "checkout #{remote}/#{branch_name}"
end
end