Hook: checking the staged files.

def pre_commit_hook(argv):
    """Hook: checking the staged files."""
    options = get_options()
    # Check if the repo has a configuration repo
    options.update(_read_local_kwalitee_configuration())

    files = []
    for filename in _get_files_modified():
        # get the staged version of the file and
        # write the staged version to temp dir with its full path to
        # avoid overwriting files with the same name
        _, stdout, _ = run("git show :{0}".format(filename), raw_output=True)
        files.append((filename, stdout))

    errors = _pre_commit(files, options)

    for error in errors:
        if hasattr(error, "decode"):
            error = error.decode()
        click.echo(error, file=sys.stderr)

    if errors:
        click.echo(
            "Aborting commit due to kwalitee errors (override with "
            "'git commit --no-verify').",
            file=sys.stderr)
        raise click.Abort
    return 0