(
    ctx: click.Context, precommit_args: List[str]
)
scan as a pre-commit git hook.
scan as a pre-commit git hook.
scan as a pre - commit git hook .
def precommit_cmd(
    ctx: click.Context, precommit_args: List[str]
) -> int:  # pragma: no cover
    """
    scan as a pre-commit git hook.
    """
    config = ctx.obj["config"]
    output_handler = TextOutputHandler(
        show_secrets=config.show_secrets, verbose=config.verbose, output=None
    )
    try:
        check_git_dir()
        results = Commit(exclusion_regexes=ctx.obj["exclusion_regexes"]).scan(
            client=ctx.obj["client"],
            cache=ctx.obj["cache"],
            matches_ignore=config.matches_ignore,
            all_policies=config.all_policies,
            verbose=config.verbose,
            mode_header=SupportedScanMode.PRE_COMMIT.value,
            banlisted_detectors=config.banlisted_detectors,
        )

        return output_handler.process_scan(
            ScanCollection(id="cached", type="pre-commit", results=results)
        )
    except Exception as error:
        return handle_exception(error, config.verbose)
def precommit_cmd ( ctx : click . Context , precommit_args : List [ str ] ) -> int : # pragma: no cover config = ctx . obj [ "config" ] output_handler = TextOutputHandler ( show_secrets = config . show_secrets , verbose = config . verbose , output = None ) try : check_git_dir ( ) results = Commit ( exclusion_regexes = ctx . obj [ "exclusion_regexes" ] ) . scan ( client = ctx . obj [ "client" ] , cache = ctx . obj [ "cache" ] , matches_ignore = config . matches_ignore , all_policies = config . all_policies , verbose = config . verbose , mode_header = SupportedScanMode . PRE_COMMIT . value , banlisted_detectors = config . banlisted_detectors , ) return output_handler . process_scan ( ScanCollection ( id = "cached" , type = "pre-commit" , results = results ) ) except Exception as error : return handle_exception ( error , config . verbose )