我有一个pre-commit
git钩子,如果添加的行未遵循指定的样式指南,该钩子应该会阻止提交。
因此在我的仓库的根文件夹中,我有一个.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
下,具有完整权限:rwxrwxrwx
(我知道不是最安全的)。
#!/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
如果我将LINT
变量更改为out注释,则该钩子有效。然后,它标记了要长的行。但是,如果我改为指定配置文件,则不会对其进行标记。
我认为错误是--config="../../.flake8
不正确。我正在cygwin下的Windows机器上运行它(因此路径的格式应该正确,不是吗?)。
或者我的配置文件不正确,因此无法应用。
答案 0 :(得分:1)
挂钩在存储库的根目录中运行,因此选项应该仅为 <div class="custom-file">
<input type="file" class="custom-file-input"
aria-describedby="txtFileUpload" accept=".csv">
<label class="custom-file-label" id="txtFileUpload" >Choose file</label>
</div>