Closed yufeikang closed 1 month ago
Sorry, I may not have time to go into 1 except that to me, it's the modern approach to sharing hooks and simpler.
As for 2, you can disable husky installation by setting HUSKY=0
which would prevent core.hooksPath
to be changed. Another approach is to have global code run in ~/.config/husky/init.sh
. This way, you can have global then local code run.
Troubleshoot
Context I'm reaching out to inquire about the current design choice in Husky where it configures the
core.hooksPath
to point to a project-specific directory (e.g.,.husky
) for Git hooks, rather than directly placing hook files into the project's.git/hooks
directory. This approach seems to override the ability for global hooks set through a user's globalcore.hooksPath
configuration to be executed.In my workflow, I have global hooks that I use across multiple projects for personal utilities and checks. However, I noticed that when a project utilizes Husky, my global hooks no longer execute due to Husky's redirection of the
core.hooksPath
.Questions and Concerns:
Design Rationale: Could you please elaborate on the reasoning behind choosing to modify the
core.hooksPath
over directly writing to the project's.git/hooks
directory? I'm interested in understanding the benefits or constraints that led to this decision.Global Hooks Compatibility: Is there a recommended approach or best practice for maintaining the functionality of global Git hooks alongside Husky-managed project hooks? Any advice on how to configure my environment to allow both project-specific hooks managed by Husky and my global hooks to coexist and work properly would be greatly appreciated.
Possible Enhancements: Are there plans to address this compatibility issue in future releases, or could there be potential features added to Husky that would allow better interoperability with global Git hooks?
Technical Details:
Thank you for your time and assistance. Husky has been a valuable tool for automating and enforcing project-specific hooks, and I'm looking forward to finding a solution that accommodates both project and global hook needs.