fix: scope doctor branch checks to current repository only#9
Merged
Conversation
Root cause: Doctor() called cs.ListAll() which returns capsules from ALL repositories, then checked every capsule's branch against the current repo root via git.BranchExists(caps.Branch, root). Capsules belonging to other repos reported false missing-branch warnings. Fix: 1. Resolve current repository ID via git.RepoID(root) in Doctor(). 2. Guard branch check with caps.RepositoryID == currentRepoID so only capsules belonging to the current repo are checked. 3. Normalize path separators in git.RepoID (filepath.ToSlash) so that Windows paths from os.MkdirTemp (\ separators) and from git rev-parse --show-toplevel (/ separators) produce the same hash, preventing spurious repo-ID mismatches. Tests (9 functions, all use isolated t.TempDir + TASKCAPSULE_HOME): - Current repo capsule branch IS checked - Other-repo capsule NOT checked against current repo - Missing branch in current repo IS reported - Valid branch NOT reported - Same-name across repos: no duplicate false warning - Doctor does not mutate state - Missing worktree IS reported - Missing branch in other repo NOT reported when run from current repo - Signal-0 behavior preserved Existing tests audited: all use t.TempDir for state; no leakage into real ~/.taskcapsule directory.
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.
Root Cause
\Doctor()\ called \cs.ListAll()\ which returns capsules from ALL repositories, then checked every capsule's branch against the current repo root via \git.BranchExists(caps.Branch, root). Capsules belonging to other repos reported false \�ranch no longer exists\ warnings.
Fix
Worktree existence and stale-PID checks remain global — they do not depend on which repository is current.
Tests
9 test functions in \internal/app/doctor_test.go, all using isolated \ .TempDir\ + \TASKCAPSULE_HOME:
Validation