def create(upstream = false)
original_branch, local_branch = prepare
if local.uncommitted_changes?
puts 'You have uncommitted changes.'
puts 'Please stash or commit before creating the request.'
return
end
if local.new_commits?(upstream)
if server.request_exists_for_branch?(upstream)
puts 'A pull request already exists for this branch.'
puts 'Please update the request directly using `git push`.'
return
end
remote = local.remote_for_branch(local_branch) || 'origin'
git_call(
"push --set-upstream #{remote} #{local_branch}", debug_mode, true
)
server.send_pull_request upstream
git_call "checkout #{original_branch}"
else
puts 'Nothing to push to remote yet. Commit something first.'
end
end