我想制作一个符合 \xe2\x80\x99s REUSE标准的 Git 存储库。我想使用重用预提交挂钩来帮助确保 I\xe2\x80\x99m 兼容。重用规范要求我创建一个名为 \xe2\x80\x9cLICENSES\xe2\x80\x9d 的文件夹,其中包含我的项目使用的每个许可证。我\xe2\x80\x99m 使用其他几个挂钩,并且我不希望这些挂钩检查或修改文件夹中的任何内容LICENSES/。我希望除重用之外的每个钩子都排除在外LICENSES/。(旁注:目前,重用挂钩似乎不受 排除 的影响LICENSES/,但这可能应该得到修复)。这里\xe2\x80\x99是我迄今为止尝试过的:
exclude: \'^LICENSES/\'\nrepos:\n -\n repo: https://github.com/pre-commit/pre-commit-hooks\n rev: v4.0.1\n hooks:\n - id: check-case-conflict\n - id: end-of-file-fixer\n - id: mixed-line-ending\n - id: trailing-whitespace\n # I\xe2\x80\x99m using identity instead of reuse here for testing and to better\n # illustrate the problem.\n -\n repo: meta\n hooks:\n -\n id: identity\n exclude: "^$"\nRun Code Online (Sandbox Code Playgroud)\n那\xe2\x80\x99 不起作用。看起来除了全局模式之外,每个钩子排除模式也适用。我希望应用每个钩子排除模式而不是全局模式。
\n我可以在每个钩子上使用每个钩子排除模式,除了一个:
\nrepos:\n -\n repo: https://github.com/pre-commit/pre-commit-hooks\n …Run Code Online (Sandbox Code Playgroud) 让\xe2\x80\x99s 说我有一个包含子模块的Git 存储库:
\n$ mkdir main-worktree\n$ cd main-worktree\n$ git init\nInitialized empty Git repository in /\xe2\x80\xa6/main-worktree/.git/\n$ git submodule add https://github.com/octocat/Hello-World.git Hello-World\nCloning into \'/\xe2\x80\xa6/main-worktree/Hello-World\'...\nremote: Enumerating objects: 13, done.\nremote: Total 13 (delta 0), reused 0 (delta 0), pack-reused 13\nReceiving objects: 100% (13/13), done.\n$ git commit -m \'Create submodule\'\n[main (root-commit) 66070b6] Create submodule\n 2 files changed, 4 insertions(+)\n create mode 100644 .gitmodules\n create mode 160000 Hello-World\nRun Code Online (Sandbox Code Playgroud)\n\n$ git worktree add ../secondary-worktree\nPreparing worktree (new branch \'secondary-worktree\')\nHEAD …Run Code Online (Sandbox Code Playgroud)