Skip to content

pre-commit will not get patched when running git commit #17

@florianfischer91

Description

@florianfischer91

When the script .git/hooks/pre-commit will be called because of a git commit, pre-commit will not get patched.

Steps to reproduce:

# prepare and activate your virtual environment (with uv)
pre-commit install --install-hooks
.git/hooks/pre-commit

The output will not contain the log Using pre-commit with ..., because the condition
os.path.split(calling)[1] == f"pre-commit{'.exe' if sys.platform == 'win32' else ''}" is false.

sys.argv: ['-m', 'hook-impl', '--config=.pre-commit-config.yaml', '--hook-type=pre-commit', '--hook-dir', '<path to repo>/.git/hooks', '--']

Even if i could force the patch with the env var, it would be cool when the patching would work without it.
Don't know if it would be a solution to extend the condition with something like ... or 'hook-impl' in sys.argv ?

PS.: I think the actual root cause is that when calling python3 -m pre-commit, the path to the pre-commit binary is not in sys.argv

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions