Пример #1
0
async def test_new_upstream_commits_to_pull_down(mock_input_a):
    """
    Test case for "origin/review-branch has new commits that I must pull down"
    (no new local commits that origin doesn't have yet)
    """
    with temp_repo() as upstream:
        upstream_default_branch = upstream.active_branch
        upstream_feature_branch = upstream.create_head("feature-123")
        # upstream_feature_branch.checkout()
        with temp_repo_clone(upstream, ['feature-123']) as downstream:
            assert ", ".join(sorted_repo_branch_names(
                downstream)) == f"feature-123, {upstream_default_branch.name}"
            upstream_feature_branch.checkout()
            create_git_history(upstream, [
                (('file_0.txt', 'content for file 0'), 'second commit'),
                (('file_1.txt', 'content for file 1'), 'third commit'),
                (('file_2.txt', 'content for file 2'), 'fourth commit'),
            ])
            upstream_default_branch.checkout()
            assert upstream.active_branch.name in ['main', 'master']
            downstream.heads['feature-123'].checkout()
            opts = ValidateOptions(
                ValidateCLIOptions(verbose=False,
                                   cwd=downstream.working_dir,
                                   auto_fetch=True))
            assert opts.is_verbose() == False
            with fake_cliux(log_level=INFO) as (cli, get_lines):
                assert cli.log_level == INFO
                await do_validate(cli=cli, opts=opts)
                assert strip_ansi(
                    "".join(get_lines())
                ) == """determined that local branch feature-123 tracks upstream branch feature-123 on remote origin
Пример #2
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)
Пример #3
0
def test_verbosity_passthrough():
    o = ValidateOptions(ValidateCLIOptions(verbose=True))
    assert o.is_verbose() is True, "--verbose results in isVerbose() returning True"

    o2 = ValidateOptions(ValidateCLIOptions())
    assert o2.is_verbose() is False, "--verbose results in isVerbose() returning False"