Problem
The prepare script is test -d .git && husky install || true. In a linked git worktree, .git is a file rather than a directory, so husky install is skipped and .husky/_/husky.sh is never created. core.hooksPath=.husky lives in the shared repo config, so the hooks still run, and every commit then fails:
.husky/commit-msg: line 2: .husky/_/husky.sh: No such file or directory
Reproduction: git worktree add ../wt origin/master && cd ../wt && npm ci && git commit --allow-empty -m "test: x"
Plan
- Change the guard to
test -e .git. husky 8 itself only checks that .git exists (fs.existsSync('.git')), so it supports worktrees once it is invoked.
- Add a test that runs the
prepare script in a temporary linked worktree and in a normal checkout, and asserts that .husky/_/husky.sh exists in both.
npm run build && npm run build:test, npm run test:cli
- Open a PR with
Closes #N
Docker builds are unaffected: .git is in .dockerignore, and the Dockerfile installs with --ignore-scripts.
Problem
The
preparescript istest -d .git && husky install || true. In a linked git worktree,.gitis a file rather than a directory, sohusky installis skipped and.husky/_/husky.shis never created.core.hooksPath=.huskylives in the shared repo config, so the hooks still run, and every commit then fails:Reproduction:
git worktree add ../wt origin/master && cd ../wt && npm ci && git commit --allow-empty -m "test: x"Plan
test -e .git. husky 8 itself only checks that.gitexists (fs.existsSync('.git')), so it supports worktrees once it is invoked.preparescript in a temporary linked worktree and in a normal checkout, and asserts that.husky/_/husky.shexists in both.npm run build && npm run build:test,npm run test:cliCloses #NDocker builds are unaffected:
.gitis in.dockerignore, and the Dockerfile installs with--ignore-scripts.