Open darthkurak opened 1 month ago
Hi @darthkurak,
Typically, I'd recommend disabling Husky in CI/CD pipelines by setting the environment variable HUSKY=0
. However, if you need to keep it enabled, here are two options:
.husky/_/husky.sh
file for simplicity.git clean -xf -e .husky/_/husky.sh
to preserve Husky files during cleanup. You might also find helpful insights in this(I haven't personally tested reinstalling Husky in post-checkout, but it's worth considering.) Let me know if you have any questions!
But how is disabling with HUSKY=0 supposed to work?
It fails on the first line in post-checkout
: . "$(dirname "$0")/_/husky.sh"
Isn't too early for HUSKY=0 to work? :)
You're right now I understand the problem,
I would say this is outside the Husky.Net scope, you need to adjust your CI/CD pipeline to either avoid using git clean
in a way that removes necessary files for your project setup or somehow explicitly restore the husky.sh
file after the git clean step, (maybe even copy it manually in a separate step after git clean, since this file rarely changes)
Version
Newest
Details
I have an advanced build system in Nuke for my .NET apps. That build system makes sure that
dotnet husky install
is called each time when I build the app. It works almost perfectly fine. I have one issue in CI/CD case. When my Azure DevOps pipeline usesgit checkout
task, and this is not a first run - I am getting:.husky/post-checkout: 2: .: Can't open .husky/_/husky.sh
error. I debugged this and the flow is following:git clean
which removes_/husky.sh
(because it is not committed) - but git hook already exists. So,git checkout
fails due to missing_/husky.sh
from.husky/post-checkout
.What is the best recommendation here? I found a few workarounds, but I am not sure if they are valid and proper:
_/husky.sh
inpost-checkout
scriptdotnet husky install
inpost-checkout
script_/husky.sh
and change_/.gitignore
from*
tocache
- this one unfortunately is overridden each time when someone/something rundotnet husky install
Steps to reproduce
I described above.