2

I have a React project named x-y-z which has a private remote repo.
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 up a pre-commit hook.
The pre-commit hook is working fine for the parent project (x-y-z), but it is not working for the submodule project (a-b-c).

I cannot figure out anything. Can anyone please suggest a workaround?

pre-commit

#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run pre-commit

pre-commit script

"pre-commit": "lint-staged",

lint-staged config

module.exports = {
  '*.(js|jsx)': ['npm run prettify', 'npm run lint'],
  '*.(html|css|scss|json)': ['npm run prettify'],
};
phd
  • 82,685
  • 13
  • 120
  • 165
Aniket Kolekar
  • 383
  • 6
  • 19

1 Answers1

2

Submodules are separate repositories, hooks in the superproject don't work in submodules. You need to install and configure the hook into all the submodules where you want the hook to work.

phd
  • 82,685
  • 13
  • 120
  • 165
  • Thanks for bringing it up. Yes, that ia correct - submodules are separate repositories. But, I just want to know, how can we use or apply the parents configs to them. For not only one user, but all of them. – Aniket Kolekar Jun 05 '21 at 18:03
  • @AniketKolekar No way, sorry. Git doesn't have a concept of "parent config". As separate repositories submodules have their own config files and global config files, that's all. – phd Aug 08 '22 at 09:32