0

I want to combine ggshield(by GitGuardian) and Husky into one pre-commit hook, but the result is that only one of them works.

I tried run pre-commit install in repo and after this run husky install in repo. In that case when i tryed to make commit with test errors Husky work but ggshield don't work.

Also after that i tried run git config --unset-all core.hooksPath for unset git hooks in repo, and run husky install in repo, and after this run pre-commit install and received an error: Cowardly refusing to install hooks with 'core.hooksPath' set.

After this i run git config --unset-all core.hooksPath and then run pre-commit install then ggshield will work. But as soon as I run the husky install command, Husky starts working and ggshield stops working.

It turns out that only one of the git hooks can work at a time? Or is there some way to combine them?

anthony sottile
  • 61,815
  • 15
  • 148
  • 207
Sergei
  • 1
  • 1
  • 1
    `pre-commit` by default will also run the pre-existing husky hooks when they were installed first -- are you not seeing that? (so `husky install && pre-commit install` should do what you want) -- unless husky is automatically modifying `core.hooksPath` which seems quite a bad choice on their part – anthony sottile Dec 06 '22 at 20:20
  • @Albert: anthony sottile: I described what would happen in this case: error `Cowardly refusing to install hooks with 'core.hooksPath' set`. – Sergei Dec 07 '22 at 08:06

1 Answers1

0

A Husky pre-commit hook is a shell script called .husky/pre-commit. To add ggshield to an existing hook, open your .husky/pre-commit file and append the following line to it:

ggshield secret scan pre-commit
Aurélien Gâteau
  • 4,010
  • 3
  • 25
  • 30