fix(worktree): init submodules + run prepare:worktree hook per job worktree #27

Merged
janpeter merged 1 commit from fix/worktree-submodule-and-codegen into main 2026-05-28 22:59:53 +02:00
Owner

Pairs with Scrum4Me PR #53 (adds the prepare:worktree script).

Why

npm run verify runs inside per-job git worktrees. A fresh git worktree add checks out the branch tree but NOT submodules, and verify never triggers prebuild codegen. So Scrum4Me job worktrees failed on 12 @shared/* errors (alias -> vendor/scrum4me-shared submodule, not checked out) + 4 lib/manual.generated.ts errors (gitignored). Toolchain itself works (node_modules symlinked, PR #26).

What

prepareWorktree() after the node_modules symlink (both add-paths): (1) git submodule update --init --recursive guarded on .gitmodules; (2) optional prepare:worktree npm script if the repo declares one. Best-effort.

Verified

Manual worker worktree: submodule init + manual:build -> verify GREEN (140 files / 1235 tests).

Pairs with Scrum4Me PR #53 (adds the prepare:worktree script). ## Why `npm run verify` runs inside per-job git worktrees. A fresh `git worktree add` checks out the branch tree but NOT submodules, and verify never triggers prebuild codegen. So Scrum4Me job worktrees failed on 12 `@shared/*` errors (alias -> vendor/scrum4me-shared submodule, not checked out) + 4 `lib/manual.generated.ts` errors (gitignored). Toolchain itself works (node_modules symlinked, PR #26). ## What `prepareWorktree()` after the node_modules symlink (both add-paths): (1) `git submodule update --init --recursive` guarded on .gitmodules; (2) optional `prepare:worktree` npm script if the repo declares one. Best-effort. ## Verified Manual worker worktree: submodule init + manual:build -> verify GREEN (140 files / 1235 tests).
A fresh `git worktree add` checks out the branch tree but not its
submodules, and `npm run verify` never triggers the `prebuild` codegen
that produces gitignored generated files. So job worktrees failed
lint/typecheck/test on every submodule-backed path alias (Scrum4Me's
`@shared/*` -> vendor/scrum4me-shared) and on `*.generated` imports
(lib/manual.generated.ts) — even though the toolchain itself works
(node_modules already symlinked by linkNodeModules).

prepareWorktree() now, after the node_modules symlink:
  - `git submodule update --init --recursive` (guarded on .gitmodules,
    no-op for repos without submodules)
  - runs an optional `prepare:worktree` npm script if the repo declares
    one, so repo-specific codegen stays out of this generic worker code

Both are best-effort (never fail worktree creation); a genuine failure
surfaces in verify rather than blocking the job. Verified manually in a
worker worktree: submodule init + manual:build -> `npm run verify` green
(140 files / 1235 tests).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
janpeter/scrum4me-mcp!27
No description provided.