【问题标题】:How to combine ggshield and Husky for pre-commit git hook?如何结合 ggshield 和 Husky 进行预提交 git hook?
【发布时间】:2023-01-17 21:36:10
【问题描述】:

我想将 ggshield(由 GitGuardian 提供)和 Husky 组合成一个预提交挂钩,但结果是只有其中一个有效。

我尝试在回购中运行pre-commit install,然后在回购中运行husky install。在那种情况下,当我尝试提交测试错误时,Husky 工作但 ggshield 不工作。

之后我还尝试运行 git config --unset-all core.hooksPath 以在 repo 中取消设置 git 钩子,并在 repo 中运行 husky install,然后运行 ​​pre-commit install 并收到错误:Cowardly refusing to install hooks with 'core.hooksPath' set

在此之后我运行git config --unset-all core.hooksPath 然后运行pre-commit install 然后 ggshield 将工作。但是一旦我运行 husky install 命令,Husky 就开始工作,而 ggshield 停止工作。

结果一次只有一个git hooks可以工作?或者有什么方法可以将它们结合起来吗?

【问题讨论】:

  • pre-commit 默认情况下也会在首次安装时运行预先存在的 husky 钩子——你没看到吗? (所以husky install && pre-commit install应该做你想做的事)——除非哈士奇自动修改core.hooksPath,这对他们来说似乎是一个很糟糕的选择
  • @Albert:anthony sottile:我描述了在这种情况下会发生什么:错误Cowardly refusing to install hooks with 'core.hooksPath' set

标签: javascript git pre-commit pre-commit.com husky


【解决方案1】:

Husky 预提交挂钩是一个名为 .husky/pre-commit 的 shell 脚本。要将 ggshield 添加到现有挂钩,请打开您的 .husky/pre-commit 文件并将以下行附加到它:

ggshield secret scan pre-commit

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-01-07
    • 1970-01-01
    • 2022-01-10
    • 2019-05-21
    • 2015-01-15
    • 2021-07-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多