I'm trying to set up a custom repo: local
hook with pre-commit
and running into an error message that I don't understand
My steps:
- From
C:\Python\monorepo\project1\project1_app\
(in PyCharm terminal):
pre-commit install
- Create the following file:
C:\Python\monorepo\.pre-commit-config.yaml
:
- repo: local
hooks:
- id: pre-commit
- Edited
C:\Python\monorepo\.git\hooks\pre-commit
:
pip freeze > requirements_check.txt
cmp --silent requirements_check.txt requirements.txt
if [ $? -gt 0 ];
then
echo "There are packages in the env not in requirements.txt"
echo "Aborting commit"
rm requirements_check.txt
exit 1
fi
rm requirements_check.txt
exit 0
- From
C:\Python\monorepo\project1\project1_app\
ran
pre-commit run --all-files
I want to get this running without an error (once I know the basic config setup is correct I can tweak the script for my needs), but I am currently getting an error as follows:
An error has occurred: InvalidConfigError:
==> File .pre-commit-config.yaml
==> At Config()
==> At key: repos
==> At Repository(repo='local')
==> At key: hooks
==> At Hook(id='pre-commit')
=====> Missing required key: name
Check the log at C:\Users\myusername\.cache\pre-commit\pre-commit.log
I also tried adding the "name" argument to the .pre-commit.config.yaml file, running "pre-commit clean" and retrying "pre-commit run -all-files", but I still get the same error:
repos:
- repo: local
hooks:
- id: pre-commit
- name: pre-commit
Can someone help with my pre-commit setup/config so I can avoid this error?