@task(default=True)
def merge(number):
    '''Prepare and push a pull request.'''
    author, branch = patch(number)
    upstream = env.get('huxley_upstream', 'upstream')

    print ui.info('Changes checked out. Rebasing and squashing...')
    git.rebase_remote(upstream)
    commits_ahead = git.commits_ahead(upstream)
    local('git rebase -i HEAD~%d' % commits_ahead)

    if not confirm(ui.warning('Changes squashed. Push?')):
        abort('Push canceled.')

    local('git checkout master; git merge %s --ff-only' % branch)
    git.rebase_remote(upstream)
    local('git push %s master' % upstream)

    print ui.success('Changes pushed! Deleting branch...')
    local('git branch -d %s' % branch)
dataset/ETHPy150Open bmun/huxley/fabfile/pr.py/merge/original