Don't work when .git placed in parent directory
Opened this issue ยท 23 comments
Hi! Thanks for amazing solution of hooks implementation for node.js. But could you add support for cases when .git placed in parent directory relative to package.json?
๐
๐
๐ I have different parts of the project in separate directories within a single repo, this will solve the issue.
I guess we could make this functionality opt-in by specifying the max depth that we can search for a .git
folder.
The only complication I can see, if I have multiple projects in a repository in subfolders that use pre-commit.
@tuhoojabotti That's why I'm suggesting opt-in through a field in the package.json
Yeah, I don't see an issue with that, but would it be possible to run the pre-commit hooks of all packages in sub folders? For example if I have a package.json file for both my back-end and front-end I would like to run both pre-commit hooks before allowing commit.
๐
+1
+1
Happy to give it a shot and create a PR. Could I get a hint please which part of the code to start with?
EDIT: not going to do that, was easier to just change my directory structure ๐
@kosmotaur Probably the installation script of this module: https://github.com/observing/pre-commit/blob/master/install.js#L23-L28 as it checks if the parent folder has .git
Btw, when using git submodules there will be a text file named .git
in the same folder that will have a relative path inside to where the submodule real .git
folder is.
Maybe this should be checked as well
๐
Hello, we suffer from the same issue here, and I would like to know if there is some kind of improvement to come (like the opt-in suggested by @3rd-Eden) ?
+1 Has this been addressed somehow ?
Also, yes, to avoid any cross-OS issues a simple solution I guess would be to put a file calle .git-repo or something at the root where the node_modules folder is which would point to the root of the .git repo and simply fail if not found...
+1!
We need this fix in my project with lint-staged.
I think it is very important for big projects with monorepo, when you have client/
and server/
subdirs.
@3rd-Eden how I can help with this issue?
๐
I have a .git that's in a parent directory and it seems it's not detected by pre-commit which siletely fails when I installed it.
I tried creating a fake .git/hooks
directory in the child directory where I run the npm installation and it works then.
Reading the comments I thought this was fixed?