我有一个这样的回购:
myrepo/
.git
tool1/
src/main.py
tests/test.py
.pre-commit-config.yaml
配置在哪里:
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
将条目更改为“pwd”只是为了查看 basedir 在预提交的上下文中是什么。现在,当我从 myrepo/tool1 目录运行它时pre-commit run --hook-stage=push --verbose
,pwd 会说“myrepo”,而不是“myrepo/tool1” . 我需要在 tool1 中运行,因为所有路径等都是相对的。
是否有一些设置或其他方式来运行预提交,以便基本目录是 myrepo/tool1?还是该项目真的必须存在于回购的根目录中?