Configurable git root
Opened this issue ยท 11 comments
Hello,
I have a multi-technology / single-repository project, something like that :
- project_root/
- .git/
- config
- hooks/
- api/
- composer.json
- [ php files ]
- frontend/
- package.json
- [ js files ]
- .git/
The problem is : the install.js doesn't find the .git directory, because it isn't in frontend directory but 1 level up. I don't know how to detect accuratly the git root, but maybe we can specify it manually in package.json, along side pre-commit scripts ?
it's ridicules this code doesn't check upper directories if .git
folder isn't found where the package.json
is. it's very very common not to have .git
in the same level as the package.json
file. :/
uninstalling after finding this out.
I ran into this exact same problem today!
+1
Adding something like a "pre-commit-root" key to package.json should be more than adequate for an override.
This would be incredibly useful! Someone please implement this!
run into the same issue, uninstall
Same issue here. Unfortunately.
Switched to https://github.com/typicode/husky
@macrozone Thanks for the tip, I just tried to involve Husky into our codebase together with https://github.com/okonet/lint-staged and it works like a charm!
@macrozone Appreciate it. Up and working now with husky.
Need this
Also doesn't work where cloned submodules have a '.git' file which points to the real git folder, eg:
my-project/linked-submodule/.git
the contents are :
gitdir: ../.git/modules/linked-submodule
the install.js
file bails because of the code:
var git = path.resolve(root, '.git')
, hooks = path.resolve(git, 'hooks')
, precommit = path.resolve(hooks, 'pre-commit');
//
// Bail out if we don't have an `.git` directory as the hooks will not get
// triggered. If we do have directory create a hooks folder if it doesn't exist.
//
if (!exists(git) || !fs.lstatSync(git).isDirectory()) return;
so 'git' is most definitely not a folder (just contains the 'real' location of the .git folder)
People do need this. We should just be able to configure the root as suggestions using a key in package.json as suggested. Or, it should auto detect.
Update: I also switched to https://github.com/typicode/husky - it works exactly like it should out of the box, even with the .git
folder at level up from the project files. Pre-commit could take some hints from Husky's code, to get this similar smoothness of workflow.