コード例 #1
0
def overlay(repository, files, version, debug=False):
    """
    Overlay files from the specified repository/version into the given
    directory and return None.

    :param repository: A string containing the path to the repository to be
     extracted.
    :param files: A list of `FileConfig` objects.
    :param version: A string containing the branch/tag/sha to be exported.
    :param debug: An optional bool to toggle debug output.
    :return: None
    """
    with util.saved_cwd():
        os.chdir(repository)
        _get_version(version, debug)

        for fc in files:
            if '*' in fc.src:
                for filename in glob.glob(fc.src):
                    util.copy(filename, fc.dst)
                    msg = '  - copied ({}) {} to {}'.format(
                        version, filename, fc.dst)
                    util.print_info(msg)
            else:
                if os.path.isdir(fc.dst) and os.path.isdir(fc.src):
                    shutil.rmtree(fc.dst)
                util.copy(fc.src, fc.dst)
                msg = '  - copied ({}) {} to {}'.format(
                    version, fc.src, fc.dst)
                util.print_info(msg)
コード例 #2
0
def extract(repository, destination, version, debug=False):
    """
    Extract the specified repository/version into the given directory and
    return None.

    :param repository: A string containing the path to the repository to be
     extracted.
    :param destination: A string containing the directory to clone the
     repository into.  Relative to the directory ``gilt`` is running
     in. Must end with a '/'.
    :param version: A string containing the branch/tag/sha to be exported.
    :param debug: An optional bool to toggle debug output.
    :return: None
    """
    with util.saved_cwd():
        if os.path.isdir(destination):
            shutil.rmtree(destination)

        os.chdir(repository)
        _get_version(version, debug)
        cmd = sh.git.bake(
            'checkout-index', force=True, all=True, prefix=destination)
        util.run_command(cmd, debug=debug)
        msg = '  - extracting ({}) {} to {}'.format(version, repository,
                                                    destination)
        util.print_info(msg)
コード例 #3
0
ファイル: shell.py プロジェクト: signed8bit/gilt
def overlay(ctx):  # pragma: no cover
    """Install gilt dependencies """
    args = ctx.obj.get("args")
    filename = args.get("config")
    debug = args.get("debug")
    _setup(filename)

    for c in config.config(filename):
        with fasteners.InterProcessLock(c.lock_file):
            util.print_info("{}:".format(c.name))
            if not os.path.exists(c.src):
                git.clone(c.name, c.git, c.src, debug=debug)
            if c.dst:
                git.extract(c.src, c.dst, c.version, debug=debug)
                post_commands = {c.dst: c.post_commands}
            else:
                git.overlay(c.src, c.files, c.version, debug=debug)
                post_commands = {
                    conf.dst: conf.post_commands
                    for conf in c.files
                }
            # Run post commands if any.
            for dst, commands in post_commands.items():
                for command in commands:
                    msg = "  - running `{}` in {}".format(command, dst)
                    util.print_info(msg)
                    cmd = util.build_sh_cmd(command, cwd=dst)
                    util.run_command(cmd, debug=debug)
コード例 #4
0
ファイル: git.py プロジェクト: signed8bit/gilt
def clone(name, repository, destination, debug=False):
    """Clone the specified repository into a temporary directory and return None.

    :param name: A string containing the name of the repository being cloned.
    :param repository: A string containing the repository to clone.
    :param destination: A string containing the directory to clone the
     repository into.
    :param debug: An optional bool to toggle debug output.
    :return: None
    """
    msg = "  - cloning {} to {}".format(name, destination)
    util.print_info(msg)
    cmd = sh.git.bake("clone", repository, destination)
    util.run_command(cmd, debug=debug)
コード例 #5
0
def overlay(ctx):  # pragma: no cover
    """ Install gilt dependencies """
    args = ctx.obj.get('args')
    filename = args.get('config')
    debug = args.get('debug')
    _setup(filename)

    for c in config.config(filename):
        with fasteners.InterProcessLock(c.lock_file):
            util.print_info('{}:'.format(c.name))
            if not os.path.exists(c.src):
                git.clone(c.name, c.git, c.src, debug=debug)
            if c.dst:
                git.extract(c.src, c.dst, c.version, debug=debug)
            else:
                git.overlay(c.src, c.files, c.version, debug=debug)
コード例 #6
0
def test_print_info(capsys):
    util.print_info('foo')

    result, _ = capsys.readouterr()
    assert 'foo\n' == result
コード例 #7
0
def test_print_info(capsys):
    util.print_info("foo")

    result, _ = capsys.readouterr()
    assert "foo\n" == result