fix(vcs): prefer nearest detected repository#342
Conversation
Greptile SummaryThis PR fixes VCS auto-detection so that when a Git repository is nested inside a parent Jujutsu workspace, the tool correctly selects the nearer Git adapter rather than defaulting to Jujutsu due to adapter priority order.
Confidence Score: 5/5Safe to merge — the change is a well-scoped fix with correct logic and good test coverage at both the unit and integration levels. The distance calculation using No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["detectVcs(cwd)"] --> B["resolve(cwd) → start"]
B --> C["For each adapter in vcsAdapters\n(jjAdapter, gitAdapter)"]
C --> D["adapter.detect(start)"]
D -->|null| C
D -->|detected| E["Compute distance:\nrelative(repoRoot, start)\n.split(/[\\\/]+/).filter(Boolean).length"]
E --> F{"distance < bestDistance?"}
F -->|yes| G["bestDetection = detected\nbestDistance = distance"]
F -->|no| H["keep existing bestDetection"]
G --> C
H --> C
C -->|all adapters exhausted| I["return bestDetection"]
Reviews (1): Last reviewed commit: "fix(vcs): prefer nearest detected reposi..." | Re-trigger Greptile |
Summary
.jj+.gitrepositories.Fixes #340.
Tests
bun test src/core/vcs/index.test.ts src/core/config.test.tsbun run typecheckbun testThis PR description was generated by Pi using OpenAI GPT-5