husky install fails when project is a submodule
See original GitHub issueVersion
0.5.4
Details
when running dotnet husky install from the root of my project directory, or as part of automated installation, I get an error message
.git can't be found (see https://alirezanet.github.io/Husky.Net/guide/getting-started)
Git hooks installation failed
Steps to reproduce
- create a new git repository
mkdir new_repo
cd new_repo
git init
- add existing project with husky as a sub-module
git submodule add git@github.com:alirezanet/Husky.Net.git
- build the submodule to trigger husky installation
cd Husky.Net
dotnet build
you will get the following error
MSBuild version 17.5.0+6f08c67f3 for .NET
Determining projects to restore...
.git can't be found (see https://alirezanet.github.io/Husky.Net/guide/getting-started)
Git hooks installation failed
D:\source\repos\new_repo\Husky.Net\src\Husky\Husky.csproj(61,5): error MSB3073: The command "dotnet husky install" exit
ed with code 1.
Build FAILED.
D:\source\repos\new_repo\Husky.Net\src\Husky\Husky.csproj(61,5): error MSB3073: The command "dotnet husky install" exit
ed with code 1.
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:03.52
Issue Analytics
- State:
- Created 6 months ago
- Reactions:2
- Comments:9 (7 by maintainers)
Top Results From Across the Web
Configure husky (git hooks) in submodules · Issue #192
This script helps you add the hooks in the main repository and a submodule public : "postinstall": "husky install && cd public &&...
Read more >React Setup: Git submodule is ignored by Husky - 6.0.0
Inside this project, I have another project named a-b-c which is a git submodule . I am using Husky: v6.0.0 and have set...
Read more >Error when building a react app that has husky installed
The build works if I run it after clearing the cache, but not normally. Any commit I push will trigger a build and...
Read more >How to Fix the “Fatal: Not a Git Repository” Error
In this tutorial, learn some of the reasons why the “fatal: not a git repository” error shows up—and how to fix it.
Read more >Solving “Fatal: Not A Git Repository” (Or Any Of The Parent ...
The error 'fatal: not a git repository' occurs when you try to run a Git command but are not inside a Git repository....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I agree, I think user can install husky for super project (if needed) later … so Option 2 makes more sense.
Thank you for the effort and I know it is harder than we thought … especially testing different scenarios takes time.
This turns out to be a lot more complicated than i anticipated. Our use case is pretty simple, but to handle god knows how many possible setups out there…
Example tree
Option 1: If we’re dealing with a submodule we just exit without doing anything. Options 2: If we’re in a submodule we install the hooks from the submodule in the submodule’s .git folder (which is pointed at by the .git
file
(submodules have there.git
dir in the super project.git
folder under themodules
subfolder) Option 3: Same as Option 2 but we also install the hooks in the super project.git
(I don’t personally see any valid uses for this you only want your submodule hooks to run when doing things on the submodule itself andOption 2
handles that.Let me know what you think. Should Option 3 be handled ?
PS: i also added a
IgnoreWhenSubmodule
option toinstall
when set we go with Option 1. This means i will also have to change theattach
command so it adds that option when specified. any input on what the best way to do that is welcome