Precommit check-yaml error : "expected a single document in the stream"

Precommit check-yaml error : "expected a single document in the stream"

我对这个 .pre-commit-config.yaml 文件(提取)使用预提交:

-   repo: https://github.com/pre-commit/pre-commit-hooks
    sha: v0.9.2
    hooks:
    -   id: trailing-whitespace
    -   id: end-of-file-fixer
    -   id: check-yaml

我被这个错误困住了:

Check Yaml...................Failed
hookid: check-yaml

expected a single document in the stream
  in "modules.yml", line 1, column 1
but found another document
  in "modules.yml", line 4, column 1

我的 yaml 文件的开头是:

repo: ssh://git.tranquilit.local/odoo-11-oca-tis/OCB.git
root: 8.0
branch: 8.0-tis
---
repo: ssh://git.tranquilit.local/odoo-71-tis/tis-addons.git
origin: tis
branch: 8.0
modules:
    #- attachment_rename
    #- partner_firstname
    - tis_account_analytic_recurrent_invoicing

我尝试过使用和不使用引导线 --- 但它只更改了错误的第 nb 行。

我在网上找不到任何帮助,所以如果有人能帮助我,我将不胜感激!

提前致谢,Herve

--- 在您的文件中开始一个新的 YAML 文档。所以你的文件中有两个 YAML 文档,这就是错误所抱怨的。根据 pre-commit 的文档,我假设你想把它变成一个序列:

- repo: ssh://git.tranquilit.local/odoo-11-oca-tis/OCB.git
  root: 8.0
  branch: 8.0-tis
- repo: ssh://git.tranquilit.local/odoo-71-tis/tis-addons.git
  origin: tis
  branch: 8.0
  modules:
    #- attachment_rename
    #- partner_firstname
    - tis_account_analytic_recurrent_invoicing

问题现已在预提交版本 1.1.0 中解决:https://github.com/pre-commit/pre-commit/issues/635 感谢您的帮助。

您可以通过设置 args: [--allow-multiple-documents] 来启用这个新选项,例如:

    hooks:
    -   id: check-yaml
        args: [--allow-multiple-documents]