git钩子中未应用Flake8配置

git钩子中未应用Flake8配置,git,githooks,flake8,Git,Githooks,Flake8,我有一个pre-commitgit钩子,如果添加的行没有遵循指定的样式指南,它应该会阻碍提交 因此,在我的repo的根文件夹中,我有一个.flake8文件,看起来像: [flake8] ########## FORMATTING ########## # Print the total number of errors. #count = ## Print the source code generating the error/warning in question. #show-sourc

我有一个
pre-commit
git钩子,如果添加的行没有遵循指定的样式指南,它应该会阻碍提交

因此,在我的repo的根文件夹中,我有一个
.flake8
文件,看起来像:

[flake8]

########## FORMATTING ##########
# Print the total number of errors.
#count =
## Print the source code generating the error/warning in question.
#show-source =
## Count the number of occurrences of each error/warning code and print a report.
#statistics =

########## OPTIONS ##########
# Set the maximum length that any line (with some exceptions) may be.
max-line-length = 90
# Set the maximum allowed McCabe complexity value for a block of code.
max-complexity = 10

########## RULES ##########
ignore = D102,D103,E265

########## TARGETS ##########
# Redirect all output to the specified file.
#output-file = 
## Also print output to stdout if output-file has been configured.
#tee = 
我的git钩子在
.git/hooks/pre-commit
下,具有完全权限:
rwxrwx
(我知道不是最安全的)

如果我将
LINT
变量更改为out注释的变量,钩子就会工作。然后,它标记了太长的行。但是如果我指定我的配置文件,那么它不会标记它

我认为错误可能是
--config=“../../.flake 8
不正确。我正在cygwin下的windows计算机上运行它(因此路径的格式应该正确,否?)


或者我的配置文件不正确,因此无法应用。

钩子运行在存储库的根目录中,因此选项应该是
--config=.flake 8

#!/bin/sh
#
# Checks so that the file is correctly linted, before commiting.
# Using the same linter settings as defined in the repo root .flake8
#

LINT=$(git diff -- '***.py' | py -3 -m flake8 --diff --config="../../.flake8")
#LINT=$(git diff -- '***.py' | py -3 -m flake8 --diff --max-line-length=90)

if [ -z "$LINT" ]
then
        exit 0
else
        echo "$LINT"
        exit 1
fi