fix: collapse worktrees to main repo, ignore $HOME-as-git-root#212
Open
NovakPAai wants to merge 1 commit into
Open
fix: collapse worktrees to main repo, ignore $HOME-as-git-root#212NovakPAai wants to merge 1 commit into
NovakPAai wants to merge 1 commit into
Conversation
resolveGitRoot now: - Uses `git worktree list --porcelain` first record to map linked worktrees to the main repo (was: separate "project" per worktree). - Drops bare-repo paths (root ending in .git) so they don't pollute downstream code expecting a working tree. - Normalizes the result via realpath so /var <-> /private/var on macOS doesn't duplicate the same physical project. - Rejects roots that equal $HOME, fixing the bug where sessions launched from home inherited the dotfiles repo's remote and mismapped to the wrong GitHub project. Disk cache bumped to -v2.json to invalidate stale entries. Tests: 7 cases in test/git-root-resolve.test.js - unit tests for the porcelain parser + integration tests using real `git init` / `git worktree add` / bare init / symlink in tmpdir. Deferred (tracked separately): atomic disk-cache writes (project-wide pattern), debug-log on porcelain fallback.
8 tasks
Collaborator
Author
Merge sequenceMerge this PR first. It has no conflicts with After this merges:
#213 is not safe to merge before this one — without the bare-repo skip + |
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.
Summary
Sessions whose
cwdlives inside a linked git worktree, or sessions launched from\$HOMEwhen home itself happens to be a git repo, were being mismapped to the wrong project / wrong GitHub remote in the dashboard.This PR fixes
resolveGitRoot()insrc/data.jsso the project identity (and downstream remote inference) is stable for those cases.Changes
git worktree list --porcelainis parsed for its first record (the main worktree) before falling back torev-parse --show-toplevel. Previously every linked worktree appeared as its own "project"..git(what--porcelainreports for bare repos) are dropped — downstream code assumes a working tree.fs.realpathSyncso macOS/varvs/private/vardoesn't duplicate the same physical project.\$HOME-as-git-root is rejected. When the home directory itself is a git repo (e.g. a dotfiles repo), sessions launched from home no longer inherit that remote.-v2.jsonto invalidate stale entries from before the fix.Tests
test/git-root-resolve.test.js— 7 cases:_parseMainWorktree(happy path, empty input, lines that look like records but aren't).gitinos.tmpdir(): linked worktree → main, bare repo → empty, symlink → normalized to real path,\$HOME-as-git-root → empty (skipped if home isn't a repo on the machine).All 7 pass locally. Pre-existing
test/wsl-windows.test.jsfailure on macOS is unrelated to this change.Deferred (out of scope)
writeFileSync→ tmp + rename). Project-wide pattern in the existing cache helpers; addressing it here would balloon the diff.rev-parsefallback. Zero-dependency project has no logger; left as a comment-level TODO.Test plan
node --test test/git-root-resolve.test.js— all 7 pass.cwdwas a linked worktree now group under the main repo's project card.cwdis\$HOME(when home is a git repo) no longer carry that repo's remote.