为存储库设置 gitlint 预提交本地
Setting up gitlint pre-commit local for a repository
我正在尝试在存储库中添加 gitlint 预提交挂钩。 .pre-commit-config.yaml
文件看起来像这样:
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: local
hooks:
- id: gitlint
name: gitlint
entry: gitlint
language: system
但是,我不断收到:
- hook id: gitlint
- exit code: 253
Usage: gitlint [OPTIONS] COMMAND [ARGS]...
Try 'gitlint --help' for help.
Error: No such command '.pre-commit-config.yaml'.
这是我之后 运行:
pip install gitlint
pre-commit install --hook-type commit-msg
我做错了什么?
错误消息不是很有帮助。我只是缺少 args 和 stages 字段:
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
---
repos:
- repo: local
hooks:
- id: gitlint
name: gitlint
language: python
entry: gitlint
args: [--staged, --msg-filename]
stages: [commit-msg]
由于以下几个原因,您的配置已损坏:
- 您已经为所有
stages
配置了 gitlint
,这意味着它将 运行 在您不想要的其他 git 挂钩上(例如 pre-commit
, pre-push
, 等等)。要解决此问题,您将设置 stages: [commit-msg]
- 您还缺少一些其他设置,例如
gitlint
的正确参数等
- 此外,您正在使用
language: system
,这意味着您依赖于您的贡献者来设置工具——这 错过了预提交 的要点,并且是无支撑的逃生舱口。拥有托管工具的通常方法是重用现有存储库(见下文)或使用 additional_dependencies
以托管方式安装工具
支持的 gitlint 使用方式来自存储库本身
repos:
- repo: https://github.com/jorisroovers/gitlint
rev: '' # pick a tag / sha to use
hooks:
- id: gitlint
免责声明:我是预提交的创建者并为 gitlint
贡献了预提交支持
我正在尝试在存储库中添加 gitlint 预提交挂钩。 .pre-commit-config.yaml
文件看起来像这样:
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: local
hooks:
- id: gitlint
name: gitlint
entry: gitlint
language: system
但是,我不断收到:
- hook id: gitlint
- exit code: 253
Usage: gitlint [OPTIONS] COMMAND [ARGS]...
Try 'gitlint --help' for help.
Error: No such command '.pre-commit-config.yaml'.
这是我之后 运行:
pip install gitlint
pre-commit install --hook-type commit-msg
我做错了什么?
错误消息不是很有帮助。我只是缺少 args 和 stages 字段:
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
---
repos:
- repo: local
hooks:
- id: gitlint
name: gitlint
language: python
entry: gitlint
args: [--staged, --msg-filename]
stages: [commit-msg]
由于以下几个原因,您的配置已损坏:
- 您已经为所有
stages
配置了gitlint
,这意味着它将 运行 在您不想要的其他 git 挂钩上(例如pre-commit
,pre-push
, 等等)。要解决此问题,您将设置stages: [commit-msg]
- 您还缺少一些其他设置,例如
gitlint
的正确参数等 - 此外,您正在使用
language: system
,这意味着您依赖于您的贡献者来设置工具——这 错过了预提交 的要点,并且是无支撑的逃生舱口。拥有托管工具的通常方法是重用现有存储库(见下文)或使用additional_dependencies
以托管方式安装工具
支持的 gitlint 使用方式来自存储库本身
repos:
- repo: https://github.com/jorisroovers/gitlint
rev: '' # pick a tag / sha to use
hooks:
- id: gitlint
免责声明:我是预提交的创建者并为 gitlint
贡献了预提交支持