Exemplo n.º 1
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)
                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)
Exemplo n.º 2
0
def test_build_sh_cmd_command_with_cwd(temp_dir):
    cmd = util.build_sh_cmd('ls', cwd=temp_dir)
    assert b'/bin/ls' == cmd._path
    assert temp_dir == cmd._partial_call_args['cwd']
Exemplo n.º 3
0
def test_build_sh_cmd_command_with_args():
    cmd = util.build_sh_cmd('ls /tmp')
    assert b'/bin/ls' == cmd._path
    assert [b'/tmp'] == cmd._partial_baked_args
Exemplo n.º 4
0
def test_build_sh_cmd_simple_command():
    cmd = util.build_sh_cmd('ls')
    assert b'/bin/ls' == cmd._path
Exemplo n.º 5
0
def test_build_sh_cmd_command_with_cwd(temp_dir):
    ls = sh.ls.bake()
    cmd = util.build_sh_cmd("ls", cwd=temp_dir)
    assert ls == cmd._path.decode()
    assert temp_dir == cmd._partial_call_args["cwd"]
Exemplo n.º 6
0
def test_build_sh_cmd_command_with_args():
    ls = sh.ls.bake()
    cmd = util.build_sh_cmd("ls /tmp")
    assert ls == cmd._path.decode()
    assert [b"/tmp"] == cmd._partial_baked_args
Exemplo n.º 7
0
def test_build_sh_cmd_simple_command():
    ls = sh.ls.bake()
    cmd = util.build_sh_cmd("ls")
    assert ls == cmd._path.decode()