Ejemplo n.º 1
0
async def validate(verbose: bool, cwd: str, enabled: bool, current_branch: str,
                   color: bool, tty: bool, auto_fetch: bool,
                   commit_count_soft_fail_threshold: bool,
                   commit_count_hard_fail_threshold: bool,
                   commit_count_auto_bypass_soft_fail: bool):
    """Examine the current Git workspace and perform some sanity-checking"""
    cliOptions = ValidateCLIOptions(
        verbose=verbose,
        cwd=cwd,
        current_branch=current_branch,
        color=color,
        tty=tty,
        auto_fetch=auto_fetch,
        commit_count_soft_fail_threshold=commit_count_soft_fail_threshold,
        commit_count_hard_fail_threshold=commit_count_hard_fail_threshold,
        commit_count_auto_bypass_soft_fail=commit_count_auto_bypass_soft_fail)
    opts = ValidateOptions(cliOptions)
    log_level = DEBUG if opts.is_verbose() else INFO
    cli = CLIUX(log_level=log_level,
                supports_color=opts.is_terminal_color_supported(),
                supports_tty=opts.is_terminal_tty_supported())
    if (enabled == False):
        print(
            "skipping validation, due to '--no-enabled' CLI arg, or GIT_GUARDRAILS_ENABLED=False env variable"
        )
        return
    await do_validate(cli, opts)
Ejemplo n.º 2
0
def fake_cliux(
        supports_color: bool = False,
        supports_tty: bool = False,
        log_level: int = INFO
) -> Iterator[Tuple[CLIUX, Callable[[], List[str]]]]:
    with fake_logger(log_level) as (my_logger, get_lines):
        cli = CLIUX(supports_color=supports_color,
                    supports_tty=supports_tty,
                    log_level=log_level,
                    logger=my_logger)
        yield cli, get_lines
Ejemplo n.º 3
0
def test_cliux_creation():
    cli = CLIUX(supports_color=False, log_level=DEBUG, supports_tty=False)
    assert cli is not None