def create_deploy_branch(deploy_branch, push=True):
    """
    If there is no remote branch with name specified in ``deploy_branch``,
    create one.

    Note that default ``deploy_branch`` is ``gh-pages`` for regular
    repos and ``master`` for ``github.io`` repos.

    Return True if ``deploy_branch`` was created, False if not.
    """
    if not deploy_branch_exists(deploy_branch):
        print("Creating {} branch on doctr_remote".format(deploy_branch))
        clear_working_branch()
        run(['git', 'checkout', '--orphan', DOCTR_WORKING_BRANCH])
        # delete everything in the new ref.  this is non-destructive to existing
        # refs/branches, etc...
        run(['git', 'rm', '-rf', '.'])
        print("Adding .nojekyll file to working branch")
        run(['touch', '.nojekyll'])
        run(['git', 'add', '.nojekyll'])
        run(['git', 'commit', '-m', 'Create new {} branch with .nojekyll'.format(deploy_branch)])
        if push:
            print("Pushing working branch to remote {} branch".format(deploy_branch))
            run(['git', 'push', '-u', 'doctr_remote', '{}:{}'.format(DOCTR_WORKING_BRANCH, deploy_branch)])
        # return to master branch and clear the working branch
        run(['git', 'checkout', 'master'])
        run(['git', 'branch', '-D', DOCTR_WORKING_BRANCH])
        # fetch the remote so that doctr_remote/{deploy_branch} is resolved
        run(['git', 'fetch', 'doctr_remote'])

        return True
    return False
def create_deploy_branch ( deploy_branch , push = True ) : if not deploy_branch_exists ( deploy_branch ) : print ( "Creating {} branch on doctr_remote" . format ( deploy_branch ) ) clear_working_branch ( ) run ( [ 'git' , 'checkout' , '--orphan' , DOCTR_WORKING_BRANCH ] ) run ( [ 'git' , 'rm' , '-rf' , '.' ] ) print ( "Adding .nojekyll file to working branch" ) run ( [ 'touch' , '.nojekyll' ] ) run ( [ 'git' , 'add' , '.nojekyll' ] ) run ( [ 'git' , 'commit' , '-m' , 'Create new {} branch with .nojekyll' . format ( deploy_branch ) ] ) if push : print ( "Pushing working branch to remote {} branch" . format ( deploy_branch ) ) run ( [ 'git' , 'push' , '-u' , 'doctr_remote' , '{}:{}' . format ( DOCTR_WORKING_BRANCH , deploy_branch ) ] ) run ( [ 'git' , 'checkout' , 'master' ] ) run ( [ 'git' , 'branch' , '-D' , DOCTR_WORKING_BRANCH ] ) run ( [ 'git' , 'fetch' , 'doctr_remote' ] ) return True return False
If there is no remote branch with name specified in ``deploy_branch``,
    create one.

    Note that default ``deploy_branch`` is ``gh-pages`` for regular
    repos and ``master`` for ``github.io`` repos.

    Return True if ``deploy_branch`` was created, False if not.