Reputation: 664
I would like to create a repository for pre-commit.com hook with a hook that runs an entry located within this repository.
I have created a repository with a hook:
my-pre-commit-hook> ls -a
.pre-commit-hooks.yaml
my-script.py
with .pre-commit-hooks.yaml
:
- id: my-check
name: my-check
entry: python
args: [my-script.py]
language: system
files: '.*'
Then, from another repository I run
pre-commit try-repo ../my-pre-commit-hook
but it fails with
... can't open file '.../my-script.py': [Errno 2] No such file or directory
I would expect that pre-commit.com provides some variable which I can use in .pre-commit-hooks.yaml
to find my-script.py
, for example
- id: my-check
name: my-check
entry: python
args: [$PRE_COMMIT_REPO/my-script.py]
language: system
files: '.*'
I don't see much advantage of installing this script like https://github.com/pre-commit/pre-commit-hooks/blob/main/setup.cfg does since I have very simple script which can run from source.
Upvotes: 0
Views: 1578
Reputation: 664
Language script
allows entry
relative to the root of the hook repository, https://pre-commit.com/#script:
The
entry
should be a path relative to the root of the hook repository.
Upvotes: 2