【发布时间】:2021-11-05 09:59:45
【问题描述】:
我想创建一个符合 REUSE 的 Git 存储库。我想使用the reuse pre-commit hook 来帮助确保我合规。 The REUSE Specification 要求我创建一个名为“LICENSES”的文件夹,其中包含我的项目使用的每个许可证。我正在使用其他几个钩子,我不希望这些钩子检查或修改 LICENSES/ 文件夹中的任何内容。我希望除重用之外的每个钩子都排除LICENSES/。 (旁注:目前,重用钩子似乎不受排除 LICENSES/ 的影响,但这应该可以修复)。以下是我目前尝试过的:
exclude: '^LICENSES/'
repos:
-
repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: check-case-conflict
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
# I’m using identity instead of reuse here for testing and to better
# illustrate the problem.
-
repo: meta
hooks:
-
id: identity
exclude: "^$"
那没用。看起来除了全局模式之外,每个钩子排除模式也适用。我希望应用每个钩子排除模式而不是全局模式。
我可以在每个钩子上使用每个钩子排除模式,除了一个:
repos:
-
repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
-
id: check-case-conflict
exclude: &exclude_pattern '^LICENSES/'
-
id: end-of-file-fixer
exclude: *exclude_pattern
-
id: mixed-line-ending
exclude: *exclude_pattern
-
id: trailing-whitespace
exclude: *exclude_pattern
# I’m using identity instead of reuse here for testing and to better
# illustrate the problem.
-
repo: meta
hooks:
- id: identity
但是,我会重复自己。我认为我可以使用合并键少重复自己,但是I don’t think that those are supported。有没有办法避免重复自己或少重复自己?
【问题讨论】:
标签: git pre-commit.com