Exemplo n.º 1
0
def install_geotaxi():
    require.deb.packages(['libhiredis-dev'])
    git.checkout('GeoTaxi')
    git.pull('GeoTaxi')
    with cd('GeoTaxi'):
        require.files.directory('obj')
        run('make')
Exemplo n.º 2
0
def install_swagger_ui():
    with cd('~'):
        if not files.exists('APITaxi_swagger'):
            git.clone('https://github.com/openmaraude/APITaxi_swagger')
        git.checkout('APITaxi_swagger')
        git.pull('APITaxi_swagger')
        return path.join(run('pwd'), 'APITaxi_swagger')
Exemplo n.º 3
0
def working_copy(remote_url, path=None, branch="master", update=True,
                 use_sudo=False, user=None):
    """
    Require a working copy of the repository from the ``remote_url``.

    Clones or pulls from the repository under ``remote_url`` and checks out
    ``branch``.

    :param remote_url: URL of the remote repository (e.g.
                       https://github.com/ronnix/fabtools.git).  The given URL
                       will be the ``origin`` remote of the working copy.
    :type remote_url: str

    :param path: Absolute or relative path of the working copy on the
                 filesystem.  If this directory doesn't exist yet, a new
                 working copy is created through ``git clone``.  If the
                 directory does exist *and* ``update == True``, a
                 ``git pull`` is issued.  If ``path is None`` the ``git clone``
                 is issued in the current working directory and the directory
                 name of the working copy is created by ``git``.
    :type path: str

    :param branch: Branch to switch to after cloning or pulling.
    :type branch: str

    :param update: Whether or not to update an existing working copy via
                   ``git pull``.
    :type update: bool

    :param use_sudo: If ``True`` execute ``git`` with
                     :func:`fabric.operations.sudo`, else with
                     :func:`fabric.operations.run`.
    :type use_sudo: bool

    :param user: If ``use_sudo is True``, run :func:`fabric.operations.sudo`
                 with the given user.  If ``use_sudo is False`` this parameter
                 has no effect.
    :type user: str
    """

    if is_dir(path, use_sudo=use_sudo) and update:
        # git pull
        git.pull(path=path, use_sudo=use_sudo, user=user)

    elif is_dir(path, use_sudo=use_sudo) and not update:
        # do nothing
        return

    elif not is_dir(path, use_sudo=use_sudo):
        # git clone
        git.clone(remote_url, path=path, use_sudo=use_sudo, user=user)
        if path is None:
            path = remote_url.split('/')[-1].replace('.git', '')

    else:
        raise ValueError("Invalid combination of parameters.")

    git.checkout(path=path, branch=branch, use_sudo=use_sudo, user=user)
Exemplo n.º 4
0
def deploy_code(repo_url='', app_dir='', user='', remote='origin', branch='master'):

    raw_branch = ''
    if '/' in branch:
        remote, raw_branch = branch.split('/')

    print(green('Fetching {}'.format(remote)))
    git.fetch(app_dir, remote=remote)

    print(green('Checking out {}'.format(branch)))
    git.checkout(app_dir, branch=branch)

    print(green('Pulling updates from {}'.format(branch)))
    if raw_branch:
        git.pull(app_dir, remote=remote, branch=raw_branch)
    else:
        git.pull(app_dir, remote=remote, branch=branch)
Exemplo n.º 5
0
def working_copy(remote_url, path=None, branch="master", update=True,
                 use_sudo=False, user=None):
    """
    Require a working copy of the repository from the ``remote_url``.

    The ``path`` is optional, and defaults to the last segment of the
    remote repository URL, without its ``.git`` suffix.

    If the ``path`` does not exist, this will clone the remote
    repository and check out the specified branch.

    If the ``path`` exists and ``update`` is ``True``, it will fetch
    changes from the remote repository, check out the specified branch,
    then merge the remote changes into the working copy.

    If the ``path`` exists and ``update`` is ``False``, it will only
    check out the specified branch, without fetching remote changesets.

    :param remote_url: URL of the remote repository (e.g.
                       https://github.com/ronnix/fabtools.git).  The given URL
                       will be the ``origin`` remote of the working copy.
    :type remote_url: str

    :param path: Absolute or relative path of the working copy on the
                 filesystem.  If this directory doesn't exist yet, a new
                 working copy is created through ``git clone``.  If the
                 directory does exist *and* ``update == True``, a
                 ``git fetch`` is issued.  If ``path is None`` the
                 ``git clone`` is issued in the current working directory and
                 the directory name of the working copy is created by ``git``.
    :type path: str

    :param branch: Branch to check out.
    :type branch: str

    :param update: Whether or not to fetch and merge remote changesets.
    :type update: bool

    :param use_sudo: If ``True`` execute ``git`` with
                     :func:`fabric.operations.sudo`, else with
                     :func:`fabric.operations.run`.
    :type use_sudo: bool

    :param user: If ``use_sudo is True``, run :func:`fabric.operations.sudo`
                 with the given user.  If ``use_sudo is False`` this parameter
                 has no effect.
    :type user: str
    """

    command()

    if path is None:
        path = remote_url.split('/')[-1].rstrip('.git')

    if is_dir(path, use_sudo=use_sudo) and update:
        git.fetch(path=path, use_sudo=use_sudo, user=user)
        git.checkout(path=path, branch=branch, use_sudo=use_sudo, user=user)
        git.pull(path=path, use_sudo=use_sudo, user=user)

    elif is_dir(path, use_sudo=use_sudo) and not update:
        git.checkout(path=path, branch=branch, use_sudo=use_sudo, user=user)

    elif not is_dir(path, use_sudo=use_sudo):
        git.clone(remote_url, path=path, use_sudo=use_sudo, user=user)
        git.checkout(path=path, branch=branch, use_sudo=use_sudo, user=user)

    else:
        raise ValueError("Invalid combination of parameters.")
Exemplo n.º 6
0
def working_copy(remote_url,
                 path=None,
                 branch="master",
                 update=True,
                 stash=True,
                 use_sudo=False,
                 user=None):
    """
    Require a working copy of the repository from the ``remote_url``.

    Clones or pulls from the repository under ``remote_url`` and checks out
    ``branch``.

    :param remote_url: URL of the remote repository (e.g.
                       https://github.com/ronnix/fabtools.git).  The given URL
                       will be the ``origin`` remote of the working copy.
    :type remote_url: str

    :param path: Absolute or relative path of the working copy on the
                 filesystem.  If this directory doesn't exist yet, a new
                 working copy is created through ``git clone``.  If the
                 directory does exist *and* ``update == True``, a
                 ``git pull`` is issued.  If ``path is None`` the ``git clone``
                 is issued in the current working directory and the directory
                 name of the working copy is created by ``git``.
    :type path: str

    :param branch: Branch to switch to after cloning or pulling.
    :type branch: str

    :param update: Whether or not to update an existing working copy via
                   ``git pull``.
    :type update: bool

    :param use_sudo: If ``True`` execute ``git`` with
                     :func:`fabric.operations.sudo`, else with
                     :func:`fabric.operations.run`.
    :type use_sudo: bool

    :param user: If ``use_sudo is True``, run :func:`fabric.operations.sudo`
                 with the given user.  If ``use_sudo is False`` this parameter
                 has no effect.
    :type user: str
    """

    if is_dir(path, use_sudo=use_sudo) and update:
        # git pull
        git.pull(path=path, use_sudo=use_sudo, user=user, stash=stash)

    elif is_dir(path, use_sudo=use_sudo) and not update:
        # do nothing
        return

    elif not is_dir(path, use_sudo=use_sudo):
        # git clone
        git.clone(remote_url, path=path, use_sudo=use_sudo, user=user)
        if path is None:
            path = remote_url.split('/')[-1].replace('.git', '')

    else:
        raise ValueError("Invalid combination of parameters.")

    git.checkout(path=path, branch=branch, use_sudo=use_sudo, user=user)
Exemplo n.º 7
0
def working_copy(remote_url, path=None, branch="master", update=True,
                 use_sudo=False, user=None):
    """
    Require a working copy of the repository from the ``remote_url``.

    The ``path`` is optional, and defaults to the last segment of the
    remote repository URL, without its ``.git`` suffix.

    If the ``path`` does not exist, this will clone the remote
    repository and check out the specified branch.

    If the ``path`` exists and ``update`` is ``True``, it will fetch
    changes from the remote repository, check out the specified branch,
    then merge the remote changes into the working copy.

    If the ``path`` exists and ``update`` is ``False``, it will only
    check out the specified branch, without fetching remote changesets.

    :param remote_url: URL of the remote repository (e.g.
                       https://github.com/ronnix/fabtools.git).  The given URL
                       will be the ``origin`` remote of the working copy.
    :type remote_url: str

    :param path: Absolute or relative path of the working copy on the
                 filesystem.  If this directory doesn't exist yet, a new
                 working copy is created through ``git clone``.  If the
                 directory does exist *and* ``update == True``, a
                 ``git fetch`` is issued.  If ``path is None`` the
                 ``git clone`` is issued in the current working directory and
                 the directory name of the working copy is created by ``git``.
    :type path: str

    :param branch: Branch to check out.
    :type branch: str

    :param update: Whether or not to fetch and merge remote changesets.
    :type update: bool

    :param use_sudo: If ``True`` execute ``git`` with
                     :func:`fabric.operations.sudo`, else with
                     :func:`fabric.operations.run`.
    :type use_sudo: bool

    :param user: If ``use_sudo is True``, run :func:`fabric.operations.sudo`
                 with the given user.  If ``use_sudo is False`` this parameter
                 has no effect.
    :type user: str
    """

    if path is None:
        path = remote_url.split('/')[-1].rstrip('.git')

    if is_dir(path, use_sudo=use_sudo) and update:
        git.fetch(path=path, use_sudo=use_sudo, user=user)
        git.checkout(path=path, branch=branch, use_sudo=use_sudo, user=user)
        git.pull(path=path, use_sudo=use_sudo, user=user)

    elif is_dir(path, use_sudo=use_sudo) and not update:
        git.checkout(path=path, branch=branch, use_sudo=use_sudo, user=user)

    elif not is_dir(path, use_sudo=use_sudo):
        git.clone(remote_url, path=path, use_sudo=use_sudo, user=user)
        git.checkout(path=path, branch=branch, use_sudo=use_sudo, user=user)

    else:
        raise ValueError("Invalid combination of parameters.")
Exemplo n.º 8
0
def install_geotaxi():
    git.pull('GeoTaxi')
    with cd('GeoTaxi/src'):
        require.files.directory('obj')
        run('make')
Exemplo n.º 9
0
def pull():
    git.pull(env.project_dir)