fix(pool): cwdInWorktree accepts dot-prefixed subdirectories#33
Open
e-jung wants to merge 1 commit into
Open
Conversation
The cwdInWorktree predicate rejected any relative path starting with a dot, so being inside a dot-prefixed subdirectory of a worktree (e.g. .venv/bin, .cache/tmp, .git-hooks) was treated as "not here", causing treehouse status to fail to mark the user as present in the worktree. Replace the rel[0] != '.' check with the same "does not escape via .." predicate already used by internal/process/detect.go: rel must be "." or must not start with "..". This is a status-display-only regression, so the impact is limited to the "you're here" marker. Add the first test for cwdInWorktree as a table-driven test covering the worktree root, regular subdirs, dot-prefixed subdirs (the bug case), and paths outside the worktree.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
treehouse statusfails to recognize the user as "here" when their cwd is inside a dot-prefixed subdirectory of a worktree (e.g.<worktree>/.venv,<worktree>/.cache,<worktree>/.git-hooks).The
cwdInWorktreepredicate rejected any relative path whose first character is a dot, so.venv/bin(relative path.venv/bin) was treated as "not in the worktree", suppressing the "you're here" marker on the owning worktree instatusoutput.This is a status-display-only bug — no data loss, no acquisition/release behavior change. Very low risk.
Approach
The
cwdInWorktreepredicate ended with:The
rel[0] != '.'check was meant to reject..escapes but also rejected every dot-prefixed subdir (.venv,.cache,.git-hooks, ...). The correct, minimal predicate already exists in-repo atinternal/process/detect.go:75:Apply that same predicate in
cwdInWorktree: the cwd is in the worktree whenrel == "."(the root) orreldoes not start with..(does not escape the root). Dot-prefixed subdirectories like.venv/binsatisfy this and are now correctly recognized.Scope
Two files, +46 / -1:
internal/pool/pool.go—cwdInWorktreeuses the same "does not escape via.." predicate asinternal/process/detect.go; adds thestringsimport.internal/pool/pool_test.go— first test forcwdInWorktree, a table-drivenTestCwdInWorktreecovering: worktree root (.), regular subdir (src/foo), dot-prefixed subdirs (.venv/bin,.cache/tmp— the bug case), the worktree parent (..), and a sibling directory.Risk
Very low.
cwdInWorktreeonly drives the "you're here" (StatusHere) marker instatusoutput — it is not on the acquisition, release, prune, or destroy paths. The new predicate matches the one already validated ininternal/process/detect.go. No data-loss surface; no behavioral change beyond the status marker.Verification
TestCwdInWorktreepasses on the fixed code./.venv/bin,/.cache/tmp) fail with= false, want true, while the root / regular-subdir / outside / sibling cases pass — exactly the regression the fix targets.go test ./...(cmd,internal/config,internal/git,internal/hooks,internal/pool,internal/process,internal/updater).go vet ./...clean;gofmtclean.Regression test transcript (buggy vs fixed)
AI disclosure
Human-reviewed. The investigation (locating the predicate and its correct counterpart in
internal/process/detect.go), the fix, and the regression test were produced autonomously and reviewed by a human operator before opening.