feat(pool): Add .worktreeinclude support#48
Conversation
mbrookson
left a comment
There was a problem hiding this comment.
Nice implementation — using git ls-files + check-ignore for pattern matching is the right call over rolling our own glob expansion. A few observations from independently building the same feature (closed #50 in favour of this):
Seeding runs inside the state lock
Both call sites invoke SeedWorktree inside the WithStateLock closure, which means the flock is held for the duration of the file copies. For repos with large ignored files this could block concurrent treehouse commands unnecessarily. The post-create hooks already run after the lock is released — seeding feels like it belongs there too, since it's not mutating pool state. Something like:
// after WithStateLock returns, before hooks.Run
if err := git.SeedWorktree(repoRoot, acquired); err != nil {
fmt.Fprintf(os.Stderr, "warning: .worktreeinclude: %v\n", err)
}(Whether to warn or hard-fail is a separate question — see below.)
excludedIncludeSubtree only handles !dir/ negations, not !file
The custom parser skips lines matching !<dir>/ but a bare negation like !.env.local won't be excluded. Given the function comment says "Git does not descend into an excluded directory", I think this is intentional — but it's worth a doc comment clarifying that file-level negations aren't supported so users don't write !secrets/prod.json and wonder why it still gets copied.
Seed errors abort acquire for the missing-file case
If .worktreeinclude lists .env but a contributor doesn't have that file locally (common on a fresh clone), git ls-files returns nothing for it and the seed silently skips it — so this is actually fine in practice. The error path that would bite is an OS-level failure mid-copy. Current behaviour (abort acquire) is defensible, though a warning-and-continue would be more resilient. Worth a deliberate decision either way.
|
Thanks for the review. I moved seeding outside the state lock and changed OS-level copy failures to warn without failing the acquire. I also clarified that Git handles file-level negations directly and added coverage for |
f7b2fe2 to
4f7b2a7
Compare
|
Automated reminder: thanks for the PR! This branch currently has a merge conflict with the base branch. When you get a chance, please rebase onto (or merge) the latest base branch, resolve the conflict, and push. After that, checks will re-run and the PR will get looked at again. Noted for treehouse#48 at |
Seed acquired worktrees after releasing the pool lock to avoid blocking concurrent commands during file copies. Treat seeding failures as warnings and document and test file-negation behavior
Keep text assertions portable across Git's Windows checkout conversion.
2bdbbfe to
c650ff6
Compare
Prevent reused ignored paths from redirecting seeded writes outside the worktree.
Filter seed candidates against the acquired worktree index so branch differences cannot dirty it.
Apply later include patterns after directory negations and read the manifest only once.
|
Rebased onto the latest main and fixed several issues found during review of
|
Intent
Resolve #39 by allowing repositories to seed required gitignored files into pooled worktrees through a committed
.worktreeincludemanifest.Changes
!local/archive/.worktreeincludeonce per acquisitionFailure behavior
Seeding is fail-open:
.worktreeincludemanifest is a no-opRisk assessment
Low to moderate.
.worktreeincluderetain existing behaviorfilepathpackageValidation
make lintpassesgo test ./...passesGOOS=windows go build ./...passe