I have a repo like this:
myrepo/
.git
tool1/
src/main.py
tests/test.py
.pre-commit-config.yaml
Where the config is:
repos:
- repo: local
hooks:
- id: pytest-cov
name: pytest coverage
stages: [push]
language: system
entry: pwd # originally: pytest testtool --cov --cov-fail-under=0
types: [python]
pass_filenames: false
Changed the entry to 'pwd' just to see what the basedir is in pre-commit's context..
Now, when I run this from the myrepo/tool1 dir, by pre-commit run --hook-stage=push --verbose
, pwd will say "myrepo", rather than "myrepo/tool1".
I would need to run in the tool1 as all paths etc are relative to that.
Is there some setting or another way to run precommit so that the base directory would be myrepo/tool1? or does the project really have to live in the root of the repo?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…