In my python project, I have pre-commit-config.YAML where I want to create my custom file.
The intention of this file is fail git commit if python lint errors are greater than certain numbers. The following command will be used to count lines
pylint api/ | wc -l
Can someone please suggest some approach. I am new to the MAC and Python ecosystem?
EDIT sh file looks like this.
#!/bin/sh
a=$(pylint source/ | wc -l)
b=20
errorsCount="$(echo "${a}" | tr -d '[:space:]')"
if [ $errorsCount -gt $b ]
then
exit 1
fi
I tried
repos:
- repo: local
hooks:
- id: custom-script-file
name: custom-script-file
entry: hooks/pre-commit.sh
language: script
types: [python]
pass_filenames: false
But it wouldn't worked.
But it wouldn't worked
could you be more specific? How did you test that it doesn't work? Any error output? – ShellishellieSkipped
? try it with--all-files
or by settingalways_run: true
(if you want it to always run) – Lownecked