Exemplo n.º 1
0
def init(ctx):
    """Initialize the project for use with EasyCI. This installs the necessary
    git hooks (pre-commit + pre-push) and add a config file if one does not
    already exists.
    """
    # install hooks
    git = ctx.obj['vcs']
    click.echo("Installing hooks...", nl=False)
    for old in ['commit-msg']:
        path = os.path.join(git.path, '.git/hooks', old)
        if os.path.exists(path):
            os.remove(path)
    for new in ['pre-commit', 'pre-push']:
        git.install_hook(new, hooks_manager.get_hook(new))
    click.echo("Done.")

    # add a config file if one does not exist
    config_path = os.path.join(git.path, 'eci.yaml')
    if not os.path.exists(config_path):
        click.echo("Placing a trivial config file in your project...",
                   nl=False)
        with open(config_path, 'w') as f:
            f.write(
                yaml.safe_dump({
                    'tests': ['echo please modify to run your tests', 'true']
                }))
        click.echo("Done.")

    # initialize lock
    locking.init(git)

    # update installed version
    click.echo("Updating installed version...", nl=False)
    set_installed_version(git, easyci.__version__)
    click.echo("Done.")
Exemplo n.º 2
0
def test_set_installed_version(fake_vcs):
    set_installed_version(fake_vcs, 'testing')
    version_path = _get_version_path(fake_vcs)
    with open(version_path, 'r') as f:
        assert f.read() == 'testing'